-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow Join type to be settable, fix #54
- Loading branch information
Showing
8 changed files
with
138 additions
and
32 deletions.
There are no files selected for viewing
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
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
62 changes: 62 additions & 0 deletions
62
...peedment/jpastreamer/streamconfiguration/standard/internal/StandardJoinConfiguration.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package com.speedment.jpastreamer.streamconfiguration.standard.internal; | ||
|
||
import com.speedment.jpastreamer.field.Field; | ||
import com.speedment.jpastreamer.streamconfiguration.StreamConfiguration; | ||
|
||
import javax.persistence.criteria.JoinType; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
|
||
final class StandardJoinConfiguration<T> implements StreamConfiguration.JoinConfiguration<T> { | ||
|
||
private final Field<T> field; | ||
private final JoinType joinType; | ||
|
||
StandardJoinConfiguration(final Field<T> field, final JoinType joinType) { | ||
this.field = requireNonNull(field); | ||
this.joinType = requireNonNull(joinType); | ||
} | ||
|
||
@Override | ||
public Field<T> field() { | ||
return field; | ||
} | ||
|
||
@Override | ||
public JoinType joinType() { | ||
return joinType; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
|
||
StandardJoinConfiguration<?> that = (StandardJoinConfiguration<?>) o; | ||
|
||
if (!field.equals(that.field)) return false; | ||
return joinType == that.joinType; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
int result = field.hashCode(); | ||
result = 31 * result + joinType.hashCode(); | ||
return result; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return label(joinType) + " on " + field.columnName(); | ||
} | ||
|
||
private static String label(final JoinType joinType) { | ||
switch (joinType) { | ||
case INNER: return "inner join"; | ||
case LEFT: return "left outer join"; | ||
case RIGHT: return "right outer join"; | ||
} | ||
return joinType.name(); | ||
} | ||
|
||
} |
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
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
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
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
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