This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static String mapToString(List<String> list, String separator, String encapsulator) { | |
StringBuilder stringBuilder = new StringBuilder(); | |
for (String item : list) { | |
if (stringBuilder.length() > 0) stringBuilder.append(separator); | |
stringBuilder.append(String.format("%1$s%2$s%1$s", encapsulator, item)); | |
} | |
return stringBuilder.toString(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* List To HashMap | |
* | |
* Converts a list of key/value pairs (in the form of String arrays) to a HashMap with values merged based on key. | |
* | |
* For example, if given the following list of arrays: | |
* | |
* [0] => { [0] => "Project A", [1] => "Asset 1" }, | |
* [1] => { [0] => "Project A", [1] => "Asset 2" }, | |
* [2] => { [0] => "Project B", [1] => "Asset 3" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Is Valid Timezone ID | |
* | |
* @param string $timezone_id Timezone ID to validate. | |
* | |
* @return bool True if timezone ID is valid; otherwise false. | |
*/ | |
function is_valid_timezone_id( $timezone_id ){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
private function map( $entity, $model ) { | |
$mapped = $entity; | |
foreach ( $entity as $key => $value ) { | |
if ( is_object( $entity ) ) { | |
if ( is_object( $value ) || is_array( $value ) ) | |
$mapped->$key = $this->map( $value, $model ); | |
else if ( property_exists( $model, $value ) ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.codehaus.jackson.annotate.JsonSubTypes; | |
import org.codehaus.jackson.annotate.JsonTypeInfo; | |
import org.codehaus.jackson.annotate.JsonTypeName; | |
import org.codehaus.jackson.map.ObjectMapper; | |
import org.testng.Assert; | |
import org.testng.annotations.Test; | |
import java.io.IOException; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Asset { | |
private AssetType type; | |
@JsonTypeInfo( | |
use = JsonTypeInfo.Id.NAME, | |
include = JsonTypeInfo.As.EXTERNAL_PROPERTY, | |
property = "type" | |
) | |
@JsonSubTypes({ | |
@JsonSubTypes.Type(value = ImageAssetProperties.class, name = "image"), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Entity | |
@Table(name = "User") | |
public class User { | |
@Id | |
@GeneratedValue(strategy = GenerationType.AUTO) | |
@Column(name = "id") | |
private Integer id; | |
@Column(name = "uuid") | |
private String uuid; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.apache.commons.lang.math.RandomUtils; | |
import org.testng.Assert; | |
import org.testng.annotations.Test; | |
public class enumStrategyPatternTest() { | |
public enum Strategy { | |
ADD { | |
@Override | |
public int execute(int a, int b) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class DateTimeUtils { | |
public static final int SECONDS_IN_DAY = 86400; | |
public static long currentTimeInSecondsGMT() { | |
return System.currentTimeMillis()/1000; | |
} | |
public static long lastMidnightTimeInSecondsGMT() { | |
return (currentTimeInSecondsGMT() / SECONDS_IN_DAY) * SECONDS_IN_DAY; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Collection; | |
import java.util.HashSet; | |
import java.util.Set; | |
import java.util.concurrent.ConcurrentSkipListMap; | |
import java.util.regex.Matcher; | |
import java.util.regex.Pattern; | |
public class SqlStringUtility { | |
/** |