[Minor] Removed redundant types (diamond operator)

This commit is contained in:
Robert von Burg 2016-02-10 17:46:50 +01:00
parent 0473b472b3
commit 3502a4adad
17 changed files with 50 additions and 50 deletions

View File

@ -182,7 +182,7 @@ public class InMemoryDao<T extends StrolchElement> implements StrolchDao<T> {
public synchronized long removeAll() {
long removed = 0;
Set<String> keySet = new HashSet<String>(this.elementMap.keySet());
Set<String> keySet = new HashSet<>(this.elementMap.keySet());
for (String type : keySet) {
Map<String, T> byType = this.elementMap.remove(type);
removed += byType.size();

View File

@ -49,7 +49,7 @@ public class InMemoryAuditQueryVisitor<U> implements AuditQueryVisitor {
long limit = auditQuery.getLimit();
return new InMemoryAuditQuery<U>(this.navigator, limit, this.selectors, auditVisitor);
return new InMemoryAuditQuery<>(this.navigator, limit, this.selectors, auditVisitor);
}
@Override

View File

@ -81,7 +81,7 @@ public class InMemoryQuery<T extends StrolchElement, U> {
if (this.comparator != null)
elements.sort(this.comparator);
List<U> result = new ArrayList<U>();
List<U> result = new ArrayList<>();
Iterator<T> iter = elements.iterator();
while (iter.hasNext()) {
T element = iter.next();

View File

@ -147,7 +147,7 @@ public abstract class GroupedParameterizedElement extends AbstractStrolchElement
*/
public void addParameter(String bagKey, Parameter<?> parameter) throws StrolchException {
if (this.parameterBagMap == null) {
this.parameterBagMap = new HashMap<String, ParameterBag>();
this.parameterBagMap = new HashMap<>();
}
ParameterBag bag = this.parameterBagMap.get(bagKey);
if (bag == null) {
@ -204,7 +204,7 @@ public abstract class GroupedParameterizedElement extends AbstractStrolchElement
*/
public void addParameterBag(ParameterBag bag) {
if (this.parameterBagMap == null) {
this.parameterBagMap = new HashMap<String, ParameterBag>();
this.parameterBagMap = new HashMap<>();
}
if (this.parameterBagMap.containsKey(bag.getId())) {
@ -284,7 +284,7 @@ public abstract class GroupedParameterizedElement extends AbstractStrolchElement
if (this.parameterBagMap == null) {
return Collections.emptySet();
}
return new HashSet<String>(this.parameterBagMap.keySet());
return new HashSet<>(this.parameterBagMap.keySet());
}
/**

View File

@ -67,7 +67,7 @@ public class Locator {
if (pathElements == null || pathElements.isEmpty()) {
throw new StrolchException("The path elements may not be null and must contain at least 1 item"); //$NON-NLS-1$
}
this.pathElements = Collections.unmodifiableList(new ArrayList<String>(pathElements));
this.pathElements = Collections.unmodifiableList(new ArrayList<>(pathElements));
}
/**
@ -105,7 +105,7 @@ public class Locator {
* the additional path
*/
private Locator(List<String> path, List<String> subPath) {
List<String> fullPath = new ArrayList<String>();
List<String> fullPath = new ArrayList<>();
fullPath.addAll(path);
fullPath.addAll(subPath);
this.pathElements = Collections.unmodifiableList(fullPath);
@ -120,7 +120,7 @@ public class Locator {
* the additional element
*/
private Locator(List<String> path, String element) {
List<String> fullPath = new ArrayList<String>();
List<String> fullPath = new ArrayList<>();
fullPath.addAll(path);
fullPath.add(element);
this.pathElements = Collections.unmodifiableList(fullPath);
@ -352,7 +352,7 @@ public class Locator {
* Default constructor
*/
public LocatorBuilder() {
this.pathElements = new ArrayList<String>();
this.pathElements = new ArrayList<>();
}
/**

View File

@ -119,10 +119,10 @@ public class AuditQuery<U> implements StrolchQuery {
}
public static AuditQuery<Audit> query(String elementTypeSelection, DateRange dateRange) {
return new AuditQuery<Audit>(new NoStrategyAuditVisitor(), elementTypeSelection, dateRange);
return new AuditQuery<>(new NoStrategyAuditVisitor(), elementTypeSelection, dateRange);
}
public static <U> AuditQuery<U> query(String elementTypeSelection, DateRange dateRange, AuditVisitor<U> orderVisitor) {
return new AuditQuery<U>(orderVisitor, elementTypeSelection, dateRange);
return new AuditQuery<>(orderVisitor, elementTypeSelection, dateRange);
}
}

View File

@ -35,7 +35,7 @@ public class TimedState<T extends IValue> implements ITimedState<T>, Serializabl
private static final long serialVersionUID = 1L;
private ITimeVariable<T> timeVariable = new TimeVariable<T>();
private ITimeVariable<T> timeVariable = new TimeVariable<>();
@Override
@SuppressWarnings("unchecked")
@ -53,7 +53,7 @@ public class TimedState<T extends IValue> implements ITimedState<T>, Serializabl
@SuppressWarnings("unchecked")
public ITimeValue<T> getPreviousMatch(final Long time, final T value) {
Collection<ITimeValue<T>> pastValues = this.timeVariable.getPastValues(time);
List<ITimeValue<T>> asList = new ArrayList<ITimeValue<T>>(pastValues);
List<ITimeValue<T>> asList = new ArrayList<>(pastValues);
Collections.reverse(asList);
for (ITimeValue<T> iTimeValue : asList) {
if (iTimeValue.getValue().matches(value)) {

View File

@ -72,7 +72,7 @@ public class TimeValue<T extends IValue> implements ITimeValue<T>, Serializable
@SuppressWarnings("unchecked")
@Override
public ITimeValue<T> getCopy() {
return new TimeValue<T>(this.time, (T) this.value.getCopy());
return new TimeValue<>(this.time, (T) this.value.getCopy());
}
@SuppressWarnings("nls")

View File

@ -34,7 +34,7 @@ public class TimeVariable<T extends IValue> implements ITimeVariable<T>, Seriali
private static final long serialVersionUID = 1L;
public SortedSet<ITimeValue<T>> container = new TreeSet<ITimeValue<T>>();
public SortedSet<ITimeValue<T>> container = new TreeSet<>();
@Override
public ITimeValue<T> getValueAt(final Long time) {
@ -55,25 +55,25 @@ public class TimeVariable<T extends IValue> implements ITimeVariable<T>, Seriali
if (current != null && current.getTime().equals(time)) {
current.setValue(targetValue);
} else {
this.container.add(new TimeValue<T>(time, targetValue));
this.container.add(new TimeValue<>(time, targetValue));
}
}
@Override
public SortedSet<ITimeValue<T>> getFutureValues(final Long time) {
TimeValue<T> picker = new TimeValue<T>(time, null);
return new TreeSet<ITimeValue<T>>(this.container.tailSet(picker));
TimeValue<T> picker = new TimeValue<>(time, null);
return new TreeSet<>(this.container.tailSet(picker));
}
@Override
public Collection<ITimeValue<T>> getPastValues(final Long time) {
TimeValue<T> picker = new TimeValue<T>(time, null);
return new TreeSet<ITimeValue<T>>(this.container.headSet(picker));
TimeValue<T> picker = new TimeValue<>(time, null);
return new TreeSet<>(this.container.headSet(picker));
}
@Override
public SortedSet<ITimeValue<T>> getValues() {
return new TreeSet<ITimeValue<T>>(this.container);
return new TreeSet<>(this.container);
}
@Override
@ -86,10 +86,10 @@ public class TimeVariable<T extends IValue> implements ITimeVariable<T>, Seriali
ITimeValue<T> initialValue = getValueAt(change.getTime());
if (initialValue == null) {
ITimeValue<T> newValue = new TimeValue<T>(change.getTime(), change.getValue());
ITimeValue<T> newValue = new TimeValue<>(change.getTime(), change.getValue());
this.container.add(newValue);
} else if (initialValue.getTime().longValue() < change.getTime().longValue()) {
ITimeValue<T> newValue = new TimeValue<T>(change.getTime(), initialValue.getValue());
ITimeValue<T> newValue = new TimeValue<>(change.getTime(), initialValue.getValue());
newValue.add(change.getValue());
this.container.add(newValue);
}

View File

@ -314,7 +314,7 @@ public class StrolchElementFromDomVisitor {
IValue<?> value = type.valueInstance(valueS);
long time = ISO8601FormatFactory.getInstance().getDateFormat().parse(timeS).getTime();
ValueChange<IValue<?>> valueChange = new ValueChange<IValue<?>>(time, value, stateId);
ValueChange<IValue<?>> valueChange = new ValueChange<>(time, value, stateId);
action.addChange(valueChange);
}

View File

@ -134,7 +134,7 @@ public class XmlModelSaxReader extends DefaultHandler {
IValue<?> value = StrolchValueType.parse(valueChangeType).valueInstance(valueChangeValue);
long valueChangeTime = ISO8601FormatFactory.getInstance().getDateFormat().parse(valueChangeTimeS).getTime();
ValueChange<IValue<?>> valueChange = new ValueChange<IValue<?>>(valueChangeTime, value, valueChangeStateId);
ValueChange<IValue<?>> valueChange = new ValueChange<>(valueChangeTime, value, valueChangeStateId);
((Action) this.parameterizedElement).addChange(valueChange);

View File

@ -28,7 +28,7 @@ import org.junit.Test;
public class TimeStateTest {
private ITimedState<FloatValue> state = new TimedState<FloatValue>();
private ITimedState<FloatValue> state = new TimedState<>();
final FloatValue expectedValue1 = new FloatValue(Double.valueOf(100D));
final FloatValue expectedValue2 = new FloatValue(Double.valueOf(200D));
@ -42,7 +42,7 @@ public class TimeStateTest {
@Before
public void before() {
final IValueChange<FloatValue> change1 = new ValueChange<FloatValue>(this.t10, this.expectedValue1);
final IValueChange<FloatValue> change1 = new ValueChange<>(this.t10, this.expectedValue1);
this.state.applyChange(change1);
final ITimeValue<FloatValue> stateAt9 = this.state.getStateAt(9L);
@ -52,7 +52,7 @@ public class TimeStateTest {
assertNotNull(stateAt11);
assertEquals(true, stateAt11.getValue().matches(this.expectedValue1));
final IValueChange<FloatValue> change2 = new ValueChange<FloatValue>(this.t30, this.expectedValue1);
final IValueChange<FloatValue> change2 = new ValueChange<>(this.t30, this.expectedValue1);
this.state.applyChange(change2);
final ITimeValue<FloatValue> stateAt31 = this.state.getStateAt(31L);

View File

@ -47,7 +47,7 @@ public class FloatTimeVariableTest {
*/
@Before
public void init() {
this.timeVariable = new TimeVariable<FloatValue>();
this.timeVariable = new TimeVariable<>();
for (long i = 0; i < MAX; i += STEP) {
this.timeVariable.setValueAt(Long.valueOf(i), new FloatValue(i));
}
@ -99,7 +99,7 @@ public class FloatTimeVariableTest {
FloatValue doubleValue = new FloatValue(STEP.doubleValue());
IValueChange<FloatValue> change = new ValueChange<FloatValue>(PICK, doubleValue);
IValueChange<FloatValue> change = new ValueChange<>(PICK, doubleValue);
this.timeVariable.applyChange(change);
Collection<ITimeValue<FloatValue>> futureValues = this.timeVariable.getFutureValues(PICK);
@ -121,11 +121,11 @@ public class FloatTimeVariableTest {
@Test
public void testApply2Change() {
this.timeVariable = new TimeVariable<FloatValue>();
this.timeVariable = new TimeVariable<>();
FloatValue doubleValue = new FloatValue(STEP.doubleValue());
IValueChange<FloatValue> change = new ValueChange<FloatValue>(PICK, doubleValue);
IValueChange<FloatValue> change = new ValueChange<>(PICK, doubleValue);
this.timeVariable.applyChange(change);
ITimeValue<FloatValue> actual = this.timeVariable.getValueAt(PICK);
@ -141,7 +141,7 @@ public class FloatTimeVariableTest {
@Test
public void testCompact() {
this.timeVariable = new TimeVariable<FloatValue>();
this.timeVariable = new TimeVariable<>();
for (Long i = 0L; i < MAX; i += STEP) {
this.timeVariable.setValueAt(i, new FloatValue(STEP.doubleValue()));
}

View File

@ -42,14 +42,14 @@ public class IntegerTimeVariableTest {
private static final Long PICK = 50L;
private TimeVariable<IntegerValue> timeVariable;
private Map<Long, IntegerValue> expectedValues = new HashMap<Long, IntegerValue>();
private Map<Long, IntegerValue> expectedValues = new HashMap<>();
/**
* set the values ascending with a difference of STEP
*/
@Before
public void init() {
this.timeVariable = new TimeVariable<IntegerValue>();
this.timeVariable = new TimeVariable<>();
for (int i = 0; i < MAX; i += STEP) {
IntegerValue expectedValue = new IntegerValue(i);
Long time = Long.valueOf(i);
@ -104,7 +104,7 @@ public class IntegerTimeVariableTest {
IntegerValue integerValue = new IntegerValue(STEP.intValue());
IValueChange<IntegerValue> change = new ValueChange<IntegerValue>(PICK, integerValue);
IValueChange<IntegerValue> change = new ValueChange<>(PICK, integerValue);
this.timeVariable.applyChange(change);
Collection<ITimeValue<IntegerValue>> futureValues = this.timeVariable.getFutureValues(PICK);
@ -124,7 +124,7 @@ public class IntegerTimeVariableTest {
*/
@Test
public void testCompact() {
this.timeVariable = new TimeVariable<IntegerValue>();
this.timeVariable = new TimeVariable<>();
for (Long i = 0L; i < MAX; i += STEP) {
this.timeVariable.setValueAt(i, new IntegerValue(STEP.intValue()));
}

View File

@ -46,13 +46,13 @@ public class StringTimeVariableTest {
private TimeVariable<IValue<Set<AString>>> timeVariable;
private Map<Long, StringSetValue> testSets = new HashMap<Long, StringSetValue>();
private Map<Long, StringSetValue> testSets = new HashMap<>();
@Before
public void init() {
this.timeVariable = new TimeVariable<IValue<Set<AString>>>();
this.timeVariable = new TimeVariable<>();
for (Long i = 0L; i < MAX; i += STEP) {
Set<AString> testSet = new HashSet<AString>();
Set<AString> testSet = new HashSet<>();
StringSetValue testValue = new StringSetValue(testSet);
this.testSets.put(i, testValue);
testSet.add(new AString("string " + i)); //$NON-NLS-1$
@ -91,15 +91,15 @@ public class StringTimeVariableTest {
@Test
public void testApplyChange() {
Set<AString> testSet = new HashSet<AString>();
Set<AString> testSet = new HashSet<>();
testSet.add(new AString("Martin")); //$NON-NLS-1$
StringSetValue testValue = new StringSetValue(testSet);
this.timeVariable = new TimeVariable<IValue<Set<AString>>>();
this.timeVariable = new TimeVariable<>();
this.timeVariable.setValueAt(PICK, testValue);
IValue<Set<AString>> inverseTestValue = testValue.getInverse();
IValueChange<IValue<Set<AString>>> change = new ValueChange<IValue<Set<AString>>>(PICK, inverseTestValue);
IValueChange<IValue<Set<AString>>> change = new ValueChange<>(PICK, inverseTestValue);
this.timeVariable.applyChange(change);
// check the future values
@ -115,9 +115,9 @@ public class StringTimeVariableTest {
@Test
public void testCompact() {
this.timeVariable = new TimeVariable<IValue<Set<AString>>>();
this.timeVariable = new TimeVariable<>();
for (Long i = 0L; i < MAX; i += STEP) {
Set<AString> testSet = new HashSet<AString>();
Set<AString> testSet = new HashSet<>();
StringSetValue testValue = new StringSetValue(testSet);
this.testSets.put(i, testValue);
testSet.add(new AString("same string")); //$NON-NLS-1$

View File

@ -62,7 +62,7 @@ public class ValueTests {
*/
@Test
public void testStringSetInverse() {
Set<AString> aStrings = new HashSet<AString>();
Set<AString> aStrings = new HashSet<>();
for (int i = 0; i < 10; i++) {
aStrings.add(new AString("string " + i)); //$NON-NLS-1$
}
@ -78,13 +78,13 @@ public class ValueTests {
@Test
public void testStringSetNearInverse() {
Set<AString> aStrings1 = new HashSet<AString>();
Set<AString> aStrings1 = new HashSet<>();
for (int i = 0; i < 10; i++) {
aStrings1.add(new AString("string " + i)); //$NON-NLS-1$
}
IValue<Set<AString>> value1 = new StringSetValue(aStrings1);
Set<AString> aStrings2 = new HashSet<AString>();
Set<AString> aStrings2 = new HashSet<>();
for (int i = 0; i < 9; i++) {
aStrings2.add(new AString("string " + i, true)); //$NON-NLS-1$
}

View File

@ -130,7 +130,7 @@ public class ServiceExecutionHandler extends StrolchComponent {
}
}
ServiceContext<T, U> svcCtx = new ServiceContext<T, U>(certificate, service, argument);
ServiceContext<T, U> svcCtx = new ServiceContext<>(certificate, service, argument);
try {
ServiceExecutionStatus status = new ServiceExecutionStatus(serviceName);
this.serviceContextMap.put(serviceName, status);