mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 20:28:00 +00:00
- CheckStyle.
This commit is contained in:
@@ -14,7 +14,7 @@ import com.google.common.base.Function;
|
|||||||
public class Aggregates {
|
public class Aggregates {
|
||||||
|
|
||||||
// Returns the value matching predicate conditions with the maximum value of whatever valueAccessor returns.
|
// Returns the value matching predicate conditions with the maximum value of whatever valueAccessor returns.
|
||||||
public final static <T> Integer max(final Iterable<T> source, final Function<T, Integer> valueAccessor) {
|
public static final <T> Integer max(final Iterable<T> source, final Function<T, Integer> valueAccessor) {
|
||||||
if (source == null) { return null; }
|
if (source == null) { return null; }
|
||||||
int max = Integer.MIN_VALUE;
|
int max = Integer.MIN_VALUE;
|
||||||
for (final T c : source) {
|
for (final T c : source) {
|
||||||
@@ -26,7 +26,7 @@ public class Aggregates {
|
|||||||
return max;
|
return max;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final static <T> Integer min(final Iterable<T> source, final Function<T, Integer> valueAccessor) {
|
public static final <T> Integer min(final Iterable<T> source, final Function<T, Integer> valueAccessor) {
|
||||||
if (source == null) { return null; }
|
if (source == null) { return null; }
|
||||||
int max = Integer.MAX_VALUE;
|
int max = Integer.MAX_VALUE;
|
||||||
for (final T c : source) {
|
for (final T c : source) {
|
||||||
@@ -39,7 +39,7 @@ public class Aggregates {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public final static <T> T itemWithMax(final Iterable<T> source, final Function<T, Integer> valueAccessor) {
|
public static final <T> T itemWithMax(final Iterable<T> source, final Function<T, Integer> valueAccessor) {
|
||||||
if (source == null) { return null; }
|
if (source == null) { return null; }
|
||||||
int max = Integer.MIN_VALUE;
|
int max = Integer.MIN_VALUE;
|
||||||
T result = null;
|
T result = null;
|
||||||
@@ -53,7 +53,7 @@ public class Aggregates {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final static <T> int sum(final Iterable<T> source, final Function<T, Integer> valueAccessor) {
|
public static final <T> int sum(final Iterable<T> source, final Function<T, Integer> valueAccessor) {
|
||||||
int result = 0;
|
int result = 0;
|
||||||
if (source != null) {
|
if (source != null) {
|
||||||
for (final T c : source) {
|
for (final T c : source) {
|
||||||
@@ -72,7 +72,7 @@ public class Aggregates {
|
|||||||
* the source
|
* the source
|
||||||
* @return the t
|
* @return the t
|
||||||
*/
|
*/
|
||||||
public final static <T> T random(final Iterable<T> source) {
|
public static final <T> T random(final Iterable<T> source) {
|
||||||
int n = 0;
|
int n = 0;
|
||||||
T candidate = null;
|
T candidate = null;
|
||||||
for (final T item : source) {
|
for (final T item : source) {
|
||||||
@@ -85,7 +85,7 @@ public class Aggregates {
|
|||||||
|
|
||||||
// Get several random values
|
// Get several random values
|
||||||
// should improve to make 1 pass over source and track N candidates at once
|
// should improve to make 1 pass over source and track N candidates at once
|
||||||
public final static <T> List<T> random(final Iterable<T> source, final int count) {
|
public static final <T> List<T> random(final Iterable<T> source, final int count) {
|
||||||
final List<T> result = new ArrayList<T>();
|
final List<T> result = new ArrayList<T>();
|
||||||
for (int i = 0; i < count; ++i) {
|
for (int i = 0; i < count; ++i) {
|
||||||
final T toAdd = Aggregates.random(source);
|
final T toAdd = Aggregates.random(source);
|
||||||
@@ -124,14 +124,18 @@ public class Aggregates {
|
|||||||
public static <TItem, TField> TItem firstFieldEquals(List<TItem> source, Function<TItem, TField> valueAccessor, TField valueEquals) {
|
public static <TItem, TField> TItem firstFieldEquals(List<TItem> source, Function<TItem, TField> valueAccessor, TField valueEquals) {
|
||||||
if (source == null) { return null; }
|
if (source == null) { return null; }
|
||||||
if (valueEquals == null) {
|
if (valueEquals == null) {
|
||||||
for (final TItem c : source)
|
for (final TItem c : source) {
|
||||||
if ( null == valueAccessor.apply(c) )
|
if (null == valueAccessor.apply(c)) {
|
||||||
return c;
|
return c;
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
for (final TItem c : source)
|
for (final TItem c : source) {
|
||||||
if ( valueEquals.equals(valueAccessor.apply(c)) )
|
if (valueEquals.equals(valueAccessor.apply(c))) {
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -255,8 +255,8 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
|
|||||||
positionAllCards();
|
positionAllCards();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void positionAllCards()
|
private void positionAllCards() {
|
||||||
{
|
|
||||||
// Position all card panels.
|
// Position all card panels.
|
||||||
int x = 0;
|
int x = 0;
|
||||||
int y = PlayArea.GUTTER_Y;
|
int y = PlayArea.GUTTER_Y;
|
||||||
|
|||||||
Reference in New Issue
Block a user