id stringlengths 36 36 | text stringlengths 1 1.25M |
|---|---|
472a8aab-5f98-4eb2-ba2d-e5ad523316c7 | @Override
public boolean isPersistent(Serializable id, Class<? extends Persistable> clazz) {
if (registry.containsDAO(clazz)) {
return registry.getDAO(clazz).isPersistent(id);
} else {
return genericDAO.isPersistent(id, clazz);
}
} |
a77597e6-abae-4f28-9273-766c7bfa41c5 | @Override
public <E extends Persistable>
E load(Serializable id, Class<E> clazz) {
if (registry.containsDAO(clazz)) {
return (E) registry.getDAO(clazz).load(id);
} else {
return genericDAO.load(id, clazz);
}
} |
164d5660-049b-47ba-aaf9-ffcb4879c4c9 | @Override
public Serializable save(Persistable entity) {
if (registry.containsDAO(entity.getClass())) {
return registry.getDAO(entity.getClass()).save(entity);
} else {
return genericDAO.save(entity);
}
} |
e6ba9333-2b5c-466c-80ef-2ad9197021eb | @Override
public void saveOrUpdate(Persistable entity) {
if (registry.containsDAO(entity.getClass())) {
registry.getDAO(entity.getClass()).saveOrUpdate(entity);
} else {
genericDAO.saveOrUpdate(entity);
}
} |
b990cd22-7a39-417c-80e5-f153080b1436 | @Override
public void update(Persistable entity) {
if (registry.containsDAO(entity.getClass())) {
registry.getDAO(entity.getClass()).update(entity);
} else {
genericDAO.update(entity);
}
} |
667c7fc3-7cae-451f-b862-b042ca407cb9 | public DelegatingSpecificDAO(GenericDAO genericDAO) {
this.genericDAO = genericDAO;
this.entityClass = determineEntityClass();
LOG.debug("Initializing {} for entity {}", this.getClass().getSimpleName(), entityClass.getSimpleName());
} |
49c475bb-787b-47b4-9efa-0ae65ab0c951 | public DelegatingSpecificDAO() {
this(null);
} |
457dfe12-4872-4260-a66b-0e83af17a684 | @Override
public Class<E> getEntityClass() {
return entityClass;
} |
d29a46c5-be91-495c-a72f-c7fda3749859 | protected GenericDAO getGenericDAO() {
return genericDAO;
} |
1875a845-de29-49b0-b244-2ae4fd799e2b | protected void setGenericDAO(GenericDAO genericDAO) {
assert genericDAO != null;
this.genericDAO = genericDAO;
} |
639e8931-47f5-4cb3-9f1b-fb1a53efbae6 | private Class<E> determineEntityClass() {
TypeVariable<?> typeVarE = DelegatingSpecificDAO.class.getTypeParameters()[0];
Type implType = this.getClass();
return (Class<E>) TypeUtils.getTypeArguments(implType, DelegatingSpecificDAO.class).get(typeVarE);
} |
eee6305c-71e2-4a03-9e2e-54ce1b183d5c | @Override
public Long count() {
return genericDAO.count(entityClass);
} |
30602513-5030-4900-8db9-6d182c958cd7 | @Override
public void delete(E entity) {
genericDAO.delete(entity);
} |
f46c336d-8c1f-42d4-bb02-a56d25ebeb22 | @Override
public void delete(ID id) {
genericDAO.delete(id, entityClass);
} |
10e5d08e-5804-448e-8c87-6801f05817e0 | @Override
public List<E> findByExample(E exampleInstance, String[] includeProperties, PagingOrdering paging) {
return genericDAO.findByExample(exampleInstance, includeProperties, paging, entityClass);
} |
d3fce46e-afe1-4ab8-a6c5-65704468844c | @Override
public E findByNaturalKey(Object naturalKey) {
return genericDAO.findByNaturalKey(naturalKey, entityClass);
} |
13be93c1-9f3d-489e-93de-eaeac9157a37 | @Override
public E findByPrimaryKey(ID id) {
return genericDAO.findByPrimaryKey(id, entityClass);
} |
65bf7470-8044-4bca-b1a7-ec81e93f66d9 | @Override
public List<E> findByProperty(String property, Object value, PagingOrdering paging) {
return genericDAO.findByProperty(property, value, paging, entityClass);
} |
15ba44f0-8c96-43d1-b279-e4d82d0e8f68 | @Override
public List<E> getAll() {
return genericDAO.getAll(entityClass);
} |
c217e161-ebf6-4304-9183-f86c6d9d6660 | @Override
public List<E> getPaginated(PagingOrdering paging) {
return genericDAO.getPaginated(paging, entityClass);
} |
94322263-68ae-4ef9-b1f2-3fec95edb7da | @Override
public boolean isPersistent(ID id) {
return genericDAO.isPersistent(id, entityClass);
} |
41da5294-de40-47c7-aa28-988b04ae18fe | @Override
public E load(ID id) {
return genericDAO.load(id, entityClass);
} |
df7131b1-9743-4c34-9d5c-f23229a55c40 | @Override
public ID save(E entity) {
return (ID) genericDAO.save(entity);
} |
b7bbe265-90e2-465d-9cca-20cbc6140976 | @Override
public void saveOrUpdate(E entity) {
genericDAO.saveOrUpdate(entity);
} |
70dbb710-0fe0-4009-a2ac-2d7dbedd511a | @Override
public void update(E entity) {
genericDAO.update(entity);
} |
91beccd7-93fa-4ae5-a5c3-b09ee360a8aa | private CompilerWarnings() {
// Constants class
} |
03c437e9-96b3-498a-a5e5-4a7abb5ea13a | public static <T> T nullsafe(@Nullable final T reference) {
if (reference != null) {
return reference;
}
throw new NullPointerException(); // NOPMD - we want to throw NPE here
} |
2b0b91de-d247-4a81-9320-a7f85ec9cc44 | public static <T> T nullsafe(@Nullable final T reference, final String message) {
if (reference != null) {
return reference;
}
throw new NullPointerException(message); // NOPMD - we want to throw NPE here
} |
c9415df4-82b7-4a1b-8dbb-97011401dd0b | private Nullsafe() {
// utility class
} |
50ec88bc-58df-486a-b429-b2a5dc3568d7 | private PMDWarnings() {
// Constants class
} |
918c93c5-58b5-4ad5-b39f-f0842a87b6a1 | private static void StartGame() throws IOException {
FourInRowPuzzle p = new FourInRowPuzzle();
Game game = new Game();
Scanner in = new Scanner(System.in);
boolean player = false;
PUZZLE_HOLE_COLORS currentColor;
short column = 0;
short maxDepth;
long startTime, endTime;
System.out.print("0: you ... |
3baa0db7-a17a-4c64-b56c-82c81cd99b4d | public static void main(String[] args) throws IOException {
StartGame();
} |
21779da9-0ddf-4b3b-8c1f-a1c925b97cd2 | public PuzzleHole() {
this.color = PUZZLE_HOLE_COLORS.NO_COLOR;
} |
522ae515-f0e1-4db5-a28a-209c982b88e6 | public PuzzleHole(PuzzleHole B) {
this.color = B.color;
} |
1bc9d511-86e7-4e38-9e22-0491d1a0e1f4 | public boolean isEmpty() {
return (this.color == PUZZLE_HOLE_COLORS.NO_COLOR);
} |
0f4c3a33-8edc-441b-a6ad-b066e4213ca6 | public boolean isRed() {
return (this.color == PUZZLE_HOLE_COLORS.RED);
} |
bc149420-838e-4ef9-aabe-9978a39f6af2 | public boolean isBlack() {
return (this.color == PUZZLE_HOLE_COLORS.BLACK);
} |
5ad90935-8398-45af-a7f5-26e4522040fa | public PUZZLE_HOLE_COLORS getColor() {
return color;
} |
decec59f-4d9e-4c23-88f1-9c829b2fc50e | public void setColor(PUZZLE_HOLE_COLORS color) {
this.color = color;
} |
5d008a79-f3de-42e7-b6fb-37d6a1cd1b7e | @Override
public String toString() {
if (this.isRed())
return "O";
else if (this.isBlack())
return "X";
return " ";
} |
1671fac6-f369-441b-bc12-6a6b2a7f715a | public FourInRowPuzzle() {
this.numberOfPlays = 0;
this.winner = PUZZLE_HOLE_COLORS.NO_COLOR;
this.holes = new PuzzleHole[6][7];
for (int i = 0; i < 6; i++) {
for (int j = 0; j < 7; j++) {
this.holes[i][j] = new PuzzleHole();
}
}
} |
e5faf731-7a21-4e62-a539-4943d8cb415e | public FourInRowPuzzle(FourInRowPuzzle B) {
this.holes = new PuzzleHole[6][7];
for (int i = 0; i < 6; i++) {
for (int j = 0; j < 7; j++) {
this.holes[i][j] = new PuzzleHole();
}
}
for (int row = 0; row < FourInRowPuzzle.hieght; row++) {
for (int column = 0; column < FourInRowPuzzle.hieght; column+... |
571cb14f-90d7-4853-941c-e26262e086cb | public boolean isEmpty() {
// check bottom row only
for (byte column = 0; column < FourInRowPuzzle.width; column++)
if (!this.holes[0][column].isEmpty())
return false;
return true;
} |
e4224274-5fea-473a-acab-9b6cd6c895bb | public boolean isFull() {
// check higher row only
for (byte column = 0; column < FourInRowPuzzle.width; column++)
if (this.holes[FourInRowPuzzle.hieght - 1][column].isEmpty())
return false;
return true;
} |
23ebb00a-8146-48c5-b561-91e4002e33e1 | public boolean isColumnFull(byte column) {
return (!this.holes[FourInRowPuzzle.hieght - 1][column].isEmpty());
} |
f672a230-e056-4cfc-a7c1-df86b507a242 | public void addToken(PUZZLE_HOLE_COLORS token, byte column) throws FullColumn {
// if column is full, throw error
if (isColumnFull(column)) {
System.out.println(this);
throw new FullColumn();
}
// to indecate at what level the token should be added
byte row = 0;
// increment untill find empty hole
... |
48655364-794a-430b-b220-205bd0f19645 | void removeToken(byte column) {
// to indecate at what level the token should be removed
byte row = (byte) (FourInRowPuzzle.hieght - 1);
// decrement untill find non empty hole
while (this.holes[row][column].isEmpty())
row--;
// set this hole with no color
this.holes[row][column].setColor(PUZZLE_HOLE_C... |
749b08d0-c965-49d9-950d-c758851e1c5e | public boolean isDone() {
// to get the current color
PUZZLE_HOLE_COLORS currentColor;
// go through all holes
for (byte row = 0; row < FourInRowPuzzle.hieght; row++) {
for (byte column = 0; column < FourInRowPuzzle.width; column++) {
// get currentcolor
currentColor = this.holes[row][column].getC... |
70a8917f-6eca-4205-8d8b-7d3f09df9903 | public PUZZLE_HOLE_COLORS getWinner() {
return this.winner;
} |
553a7c6c-c4b1-4ea9-88be-2c002313f0f2 | @Override
public String toString() {
// the string to be returned
StringBuilder aString = new StringBuilder("");
for (byte row = (byte) (FourInRowPuzzle.hieght - 1); row >= 0; row--) {
// left boundry
aString.append("| ");
for (byte column = 0; column < FourInRowPuzzle.width; column++) {
aString.... |
8f54c640-e679-4d19-af18-654ecbe33c37 | public static byte getHieght() {
return FourInRowPuzzle.hieght;
} |
31c32a94-b2bc-48c9-a1f2-60c59712d19d | public static byte getWidth() {
return FourInRowPuzzle.width;
} |
092c5e9e-0d6f-4913-9bd4-3967ae7e0366 | public int getNumberOfPlays() {
return numberOfPlays;
} |
d3a1f39e-afa7-4c30-9da4-de9873ff19df | public void setNumberOfPlays(byte numberOfPlays) {
this.numberOfPlays = numberOfPlays;
} |
5fe91a73-3a66-4d69-9510-aaff333801ec | public Game() {
// default is 5
this.maxDepth = 5;
} |
d28c03ff-a283-426a-a5ae-c72138f87dbb | public void SetPuzzle(FourInRowPuzzle aPuzzle) {
this.aPuzzle = new FourInRowPuzzle(aPuzzle);
this.originalPuzzle = new FourInRowPuzzle(aPuzzle);
} |
4ca11751-0ca5-4eea-8147-47795b86a0b5 | public void SetMaxDepth(byte maxDepth) {
this.maxDepth = maxDepth;
} |
0ca05277-b749-453b-92ee-633404c6ccaf | public short GetNextPlay() throws FullColumn {
// allocate a new graph
this.aGraph = new Graph();
// call DepthFirstSearch function
return DepthFirstSearch();
} |
7989f6e7-76c4-4102-9037-8e6e43eda864 | private short DepthFirstSearch() throws FullColumn {
// create first node
this.aGraphNode = new GraphNode();
// add it in the graph
this.aGraph.addGraphNode(this.aGraphNode);
// push it to stack
this.aStack.push(this.aGraphNode);
// while stack is not empty
while (!this.aStack.isEmpty()) {
// ge... |
80daa05a-db2d-425e-a0b6-c6776724115e | private void ApplyMove() throws FullColumn {
// check if valid play has been played
if (this.aGraphNode.tokenPosition < 7) {
// check if player1 has been played
if ((this.aGraphNode.depth & 0x01) == 0x01)
this.aPuzzle.addToken(PLAYERS.PLAYER1, this.aGraphNode.tokenPosition);
// or player2
else
t... |
f3bdd449-f061-4a1b-9edf-893c7d9be4c9 | private void RevertBackMove() {
// check if valid play has been played
if (this.aGraphNode.tokenPosition < 7)
this.aPuzzle.removeToken(this.aGraphNode.tokenPosition);
} |
2f13004d-9bc4-4533-bba6-1497872b6cec | private void PopOutOfStackAndRevertMove() {
// revert back the move
RevertBackMove();
// pop the graph node
this.aStack.pop();
} |
ebf27bd7-faac-4b6c-9f9f-15f40ff47770 | private boolean IsNeedToDevelopChildren() {
short max = SPECIAL_VALUES.NOT_ASSIGNED;
short min = SPECIAL_VALUES.NOT_ASSIGNED;
// check if parent or parents' parent are NULLS, then return true need
// to develop children
if (this.aGraphNode.parent == null || this.aGraphNode.parent.parent == null) {
return ... |
da18d8a9-cf16-41b6-a840-980bf5c6d99e | private void DevelopChildren() {
// new graph node child
GraphNode graphNodeChild;
// go through all possible next play
for (byte column = 0; column < FourInRowPuzzle.getWidth(); column++) {
// check if column is not full
if (!this.aPuzzle.isColumnFull(column)) {
// create new graph node child
g... |
7acc8ff2-bc61-4012-b221-d8f0650483fc | private short GetMaxChildValue(GraphNode aGraphNode) {
short max = SPECIAL_VALUES.NOT_ASSIGNED;
for (GraphNode g : aGraphNode.edges) {
if (g.minMaxValue != SPECIAL_VALUES.NOT_ASSIGNED && g.minMaxValue > max) {
max = g.minMaxValue;
}
}
return max;
} |
269e2425-19dc-4a5e-870f-686bbb31d808 | private short GetMinChildValue(GraphNode aGraphNode) {
short min = SPECIAL_VALUES.NOT_ASSIGNED;
for (GraphNode g : aGraphNode.edges) {
if (g.minMaxValue != SPECIAL_VALUES.NOT_ASSIGNED
&& (min == SPECIAL_VALUES.NOT_ASSIGNED || g.minMaxValue < min)) {
min = g.minMaxValue;
}
}
return min;
} |
e54dff44-bcee-4c03-b4e4-e80e970d2e5c | private void CalculateMinMaxValue() {
// check if player1 won
if (this.aPuzzle.getWinner() == PLAYERS.PLAYER1)
// set minMaxValue to win value
this.aGraphNode.minMaxValue = SPECIAL_VALUES.WIN_VALUE;
// check if player2 won
else if (this.aPuzzle.getWinner() == PLAYERS.PLAYER2)
// set minMaxValue to los... |
d5010832-f342-46da-909d-621df0283d86 | private short CountSequentials() {
return (short) (CountSequentials(PLAYERS.PLAYER1) - CountSequentials(PLAYERS.PLAYER2));
} |
46900de3-92ab-4840-a359-6e1350c9e7d8 | private short CountSequentials(PUZZLE_HOLE_COLORS color) {
// to hold the results
short result = 0;
// go through all holes
for (byte row = 0; row < FourInRowPuzzle.getHieght() - 1; row++) {
for (byte column = 0; column < FourInRowPuzzle.getWidth(); column++) {
// if this is same color token then count ... |
4328bfb8-ef79-4255-9670-3498ea8ad3b1 | private short CountCenterColumn() {
short result = 0;
// go through all holes in center column
for (byte row = 0; row < FourInRowPuzzle.getHieght() - 1; row++) {
if (this.originalPuzzle.holes[row][3].isEmpty() && this.aPuzzle.holes[row][3].getColor() == PLAYERS.PLAYER1)
result += 10;
else if (this.orig... |
ed1e5f3a-6611-4854-a276-8989c1648640 | public long GetGraphNodesCount() {
return this.aGraph.getNodeNumbers();
} |
2aa8bd17-a9f6-4a8b-aa9c-5bc4fbf711c1 | public GraphNode() {
} |
5ab93007-a077-45a6-8f91-2397af7c03a3 | void addEdge(GraphNode child) {
this.edges.addLast(child);
} |
e3990286-0f9d-40f3-ba7d-cf13ed04bf43 | public Graph() {
} |
d6e23fba-77a5-43ff-bdb9-5c8da6eab5fa | public void addGraphNode(GraphNode graphNode) {
this.graphNodes.add(graphNode);
} |
b283b130-b3a1-4074-a32c-6e5e6cd7e8ef | public void addEdge(GraphNode A, GraphNode B) {
// set child graph node's parent to current graph node
B.parent = A;
// set child graph node's depth
B.depth = (byte) (A.depth + 1);
// add B as successor of A
A.edges.addLast(B);
} |
5780b0a8-a681-4930-9914-8f81542ae20d | public GraphNode getFirstGraphNode() {
return this.graphNodes.get(0);
} |
d28f769b-c700-4d79-b81c-8080b163d737 | public long getNodeNumbers() {
return this.graphNodes.size();
} |
f9345146-1cf6-4c84-9856-aba8905261c5 | public String getText() {
return text;
} |
17d1bdaf-42bd-430d-9bf6-4ebb1c919648 | public void setText(String text) {
this.text = text;
} |
2c2ae594-422d-49dc-be0b-35181d91e723 | protected BaseModel() {
this.created = new Date();
} |
0e92543c-f481-416a-8e9f-fa88c61d14f1 | public boolean hasValidId() {
return id != null && id > 0;
} |
ccdc430f-7ebc-41ad-b00c-1680a59f4755 | public Long getId() {
return id;
} |
b8a20aa2-8175-4bff-930b-10be1d28fd6c | public void setId(Long id) {
this.id = id;
} |
6b2e1d31-442f-4f4c-9a7b-20ad6b180809 | public boolean isDeleted() {
return deleted;
} |
b6596738-f7ab-455e-88ae-57f8a9e2fc38 | public void setDeleted(boolean deleted) {
this.deleted = deleted;
} |
48637346-a7fd-4219-baf9-89d003bf9cad | public Date getCreated() {
return created;
} |
832672c5-6796-4e07-9b0e-d659ba2b90a5 | public void setCreated(Date created) {
this.created = created;
} |
30e162c4-f25c-4473-91aa-9680164b2110 | public Date getUpdated() {
return updated;
} |
79d9caa1-afc4-4b15-a1b1-ad10531aa7dc | public void setUpdated(Date updated) {
this.updated = updated;
} |
c1140d3c-d80c-492a-ab95-4b122b888a73 | @Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(this.getClass().isAssignableFrom(o.getClass()))) {
return false;
}
BaseModel baseModel = (BaseModel) o;
return id != null && id.equals(baseModel.id);
} |
00a8635c-092b-405b-b340-c205de723b79 | @Override
public int hashCode() {
if (id != null) {
return id.hashCode();
} else {
return -1;
}
} |
0091adb2-ad05-47c6-b82e-9ac765ed3a58 | public int compareTo(Object o) {
BaseModel baseModel = (BaseModel) o;
return this.id.compareTo(baseModel.getId());
} |
1068e084-6c89-40ae-a0a4-34f0d7773571 | Message addMessage(String text) throws Exception; |
ff4af54d-b564-4644-972c-c329e0a04cc3 | DeferredResult<Message> getNewMessage() throws Exception; |
fc7fe5db-6b80-469b-94e9-12d1ede93837 | public Message addMessage(String text) throws Exception {
if (!StringUtils.hasText(text)) {
throw new IllegalArgumentException("Missing required param text");
}
// create message and save
Message message = new Message();
message.setText(text);
messageDao.sa... |
7b744c69-9fe0-4c9d-984d-130df9d210ec | public void onMessage(
org.springframework.data.redis.connection.Message redisMessage,
byte[] pattern) {
Message message = (Message) SerializationUtils.deserialize(redisMessage.getBody());
// set the deferred results for the user
for (DeferredResult<Message> def... |
423fe31b-9f15-4a1c-9493-54dbb5d95266 | public DeferredResult<Message> getNewMessage() throws Exception {
final DeferredResult<Message> deferredResult =
new DeferredResult<Message>(deferredResultTimeout);
deferredResult.onCompletion(new Runnable() {
public void run() {
messageDeferredResultList.re... |
4f668c0e-4d9a-4775-9d88-33e81829796c | public void run() {
messageDeferredResultList.remove(deferredResult);
} |
c41517b4-c645-489e-bf50-bca23410ddd1 | public void run() {
messageDeferredResultList.remove(deferredResult);
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.