This file contains hidden or 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 SomeMongoTest | |
private static InMemoryMongo inMemoryMongo; | |
private static Client client; | |
@BeforeClass | |
public static void setUpClass() throws Exception { | |
inMemoryMongo = new InMemoryMongo().start(); | |
client = inMemoryMongo.getClient(); | |
} |
This file contains hidden or 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 Target { | |
private String code; | |
private String name; | |
private String publicIdentifier; | |
public Target(String code, String name, String publicIdentifier) { | |
this.code = code; | |
this.name = name; | |
this.publicIdentifier = publicIdentifier; |
This file contains hidden or 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 Target { | |
private static final Pattern ALLOWED_REGEX = Pattern.compile("[a-zA-Z\\-_]*"); | |
private String code; | |
private String name; | |
private String publicIdentifier; | |
public Target(String code, String name, String publicIdentifier) { | |
validate(code, "code"); |
This file contains hidden or 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 PublicIdentifier { | |
private static final Pattern ALLOWED_REGEX = Pattern.compile("[a-zA-Z\\-_]*"); | |
private String value; | |
public PublicIdentifier(String value) { | |
validate(value); | |
this.value = value; | |
} |
This file contains hidden or 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 interface DataSource { | |
List<Entity> getEntities(); | |
} |
This file contains hidden or 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 interface PagedDataSource { | |
List<Entity> getEntities(Paging paging); | |
} |
This file contains hidden or 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 PagedDataSourceConsumer { | |
private PagedDataSource pagedDataSource; | |
public void consume() { | |
List<Entity> entities; | |
Paging nextPage = Paging.firstPage(); | |
for(entities = pagedDataSource.getEntities(nextPage); !entities.isEmpty(); entities = pagedDataSource.getEntities(nextPage)) { | |
for(Entity entity: entities) { | |
//doStuff | |
} | |
nextPage = nextPage.next(); |
This file contains hidden or 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 com.mxgraph.canvas.mxICanvas; | |
import com.mxgraph.canvas.mxSvgCanvas; | |
import com.mxgraph.io.mxCodec; | |
import com.mxgraph.util.mxCellRenderer; | |
import com.mxgraph.util.mxDomUtils; | |
import com.mxgraph.util.mxUtils; | |
import com.mxgraph.util.mxXmlUtils; | |
import com.mxgraph.view.mxGraph; | |
public class DrawIoConverter{ |
This file contains hidden or 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 interface IteratorDataSource { | |
Iterator<Entity> getAllEntities(); | |
} |
This file contains hidden or 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 IteratorDataSourceImpl implements IteratorDataSource { | |
private PagedDataSource pagedDataSource; | |
@Override | |
public Iterator<Entity> getAllEntities() { | |
return new PagedIterator(Paging.firstPage(), (Paging paging) -> pagedDataSource.getEntities(paging).iterator()); | |
} | |
private static class PagedIterator implements Iterator<Entity> { |