Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bundles/org.eclipse.core.databinding/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.core.databinding
Bundle-Version: 1.13.600.qualifier
Bundle-Version: 1.13.700.qualifier
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Export-Package: org.eclipse.core.databinding;version="1.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ public final class AggregateValidationStatus extends ComputedValue<IStatus> {
*/
public static final int MAX_SEVERITY = 2;

private int strategy;
private IObservableCollection<? extends ValidationStatusProvider> validationStatusProviders;
private final int strategy;
private final IObservableCollection<? extends ValidationStatusProvider> validationStatusProviders;

/**
* Creates a new aggregate validation status observable for the given data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,12 @@ public Binding(IObservable target, IObservable model) {
*/
public final void init(DataBindingContext context) {
this.context = context;
if (target.isDisposed())
if (target.isDisposed()) {
throw new IllegalArgumentException("Target observable is disposed"); //$NON-NLS-1$
if (model.isDisposed())
}
if (model.isDisposed()) {
throw new IllegalArgumentException("Model observable is disposed"); //$NON-NLS-1$
}
this.disposeListener = event -> {
if (context != null) {
context.getValidationRealm().exec(Binding.this::dispose);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public class DataBindingContext {

private IObservableMap<Binding, IStatus> validationStatusMap;

private Realm validationRealm;
private final Realm validationRealm;

/**
* Creates a data binding context, using the current default realm for the
Expand Down Expand Up @@ -358,12 +358,14 @@ public final <T, M> Binding bindSet(
IObservableSet<M> modelObservableSet,
UpdateSetStrategy<? super T, ? extends M> targetToModel,
UpdateSetStrategy<? super M, ? extends T> modelToTarget) {
if (targetToModel == null)
if (targetToModel == null) {
targetToModel = createTargetToModelUpdateSetStrategy(
targetObservableSet, modelObservableSet);
if (modelToTarget == null)
}
if (modelToTarget == null) {
modelToTarget = createModelToTargetUpdateSetStrategy(
modelObservableSet, targetObservableSet);
}
targetToModel.fillDefaults(targetObservableSet, modelObservableSet);
modelToTarget.fillDefaults(modelObservableSet, targetObservableSet);
SetBinding<? super M, ? extends T> result = new SetBinding<>(targetObservableSet,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
*/
public class ObservablesManager {

private Set<IObservable> managedObservables = new IdentitySet<>();
private Set<IObservable> excludedObservables = new IdentitySet<>();
private Map<DataBindingContext, ManagerEntry> contexts = new HashMap<>();
private final Set<IObservable> managedObservables = new IdentitySet<>();
private final Set<IObservable> excludedObservables = new IdentitySet<>();
private final Map<DataBindingContext, ManagerEntry> contexts = new HashMap<>();

/**
* Create a new observables manager.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,22 +82,23 @@
private static Map<Pair, Object> converterMap;

private static Class<?> autoboxed(Class<?> clazz) {
if (clazz == Float.TYPE)
if (clazz == Float.TYPE) {
return Float.class;
else if (clazz == Double.TYPE)
} else if (clazz == Double.TYPE) {
return Double.class;
else if (clazz == Short.TYPE)
} else if (clazz == Short.TYPE) {
return Short.class;
else if (clazz == Integer.TYPE)
} else if (clazz == Integer.TYPE) {
return Integer.class;
else if (clazz == Long.TYPE)
} else if (clazz == Long.TYPE) {
return Long.class;
else if (clazz == Byte.TYPE)
} else if (clazz == Byte.TYPE) {
return Byte.class;
else if (clazz == Boolean.TYPE)
} else if (clazz == Boolean.TYPE) {
return Boolean.class;
else if (clazz == Character.TYPE)
} else if (clazz == Character.TYPE) {
return Character.class;
}
return clazz;
}

Expand Down Expand Up @@ -154,8 +155,7 @@ final protected void checkAssignable(Object toType, Object fromType,
Object converterOrClassname = converterMap.get(key);
if (converterOrClassname instanceof IConverter) {
return (IConverter<?, ?>) converterOrClassname;
} else if (converterOrClassname instanceof String) {
String classname = (String) converterOrClassname;
} else if (converterOrClassname instanceof String classname) {
Class<?> converterClass;
try {
converterClass = Class.forName(classname);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ protected IStatus doSet(IObservableValue<? super D> observableValue, D value) {

private static class ValidatorRegistry {

private Map<Pair, IValidator<?>> validators = new HashMap<>();
private final Map<Pair, IValidator<?>> validators = new HashMap<>();

/**
* Adds the system-provided validators to the current validator
Expand Down Expand Up @@ -553,8 +553,9 @@ private void associate(Object fromClass, Object toClass, IValidator<?> validator
*/
private IValidator<?> get(Object fromClass, Object toClass) {
IValidator<?> result = validators.get(new Pair(fromClass, toClass));
if (result != null)
if (result != null) {
return result;
}
if (fromClass != null && toClass != null && fromClass == toClass) {
return value -> Status.OK_STATUS;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
*/
public abstract class Converter<F, T> implements IConverter<F, T> {

private Object fromType;
private Object toType;
private final Object fromType;
private final Object toType;

/**
* @param fromType type of source values
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public void handleStale(StaleEvent staleEvent) {
}
}

private DependencyListener dependencyListener = new DependencyListener();
private final DependencyListener dependencyListener = new DependencyListener();

/**
* Constructs a MultiValidator on the default realm.
Expand Down Expand Up @@ -247,8 +247,9 @@ class ValidationRunnable implements Runnable {
public void run() {
try {
validationResult = validate();
if (validationResult == null)
if (validationResult == null) {
validationResult = ValidationStatus.ok();
}
} catch (RuntimeException e) {
// Usually an NPE as dependencies are init'ed
validationResult = ValidationStatus
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,15 @@ public int hashCode() {
*/
@Override
public boolean equals(Object obj) {
if (this == obj)
if (this == obj) {
return true;
if (obj == null)
}
if (obj == null) {
return false;
if (getClass() != obj.getClass())
}
if (getClass() != obj.getClass()) {
return false;
}
final ValidationStatus other = (ValidationStatus) obj;

return getSeverity() == other.getSeverity() && Objects.equals(getMessage(), other.getMessage())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,15 @@ public int hashCode() {

@Override
public boolean equals(Object obj) {
if (this == obj)
if (this == obj) {
return true;
if (obj == null)
}
if (obj == null) {
return false;
if (getClass() != obj.getClass())
}
if (getClass() != obj.getClass()) {
return false;
}
final BindingStatus other = (BindingStatus) obj;
return Arrays.equals(getChildren(), other.getChildren());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,16 @@ public static Class<?>[] getTypeHierarchyFlattened(Class<?> type) {
List<Class<?>> classes = null;
// cache reference to lookup to protect against concurrent flush
HashMap<Class<?>, List<Class<?>>> lookup = classSearchOrderLookup;
if (lookup != null)
if (lookup != null) {
classes = lookup.get(type);
}
// compute class order only if it hasn't been cached before
if (classes == null) {
classes = new ArrayList<>();
computeClassOrder(type, classes);
if (lookup == null)
if (lookup == null) {
classSearchOrderLookup = lookup = new HashMap<>();
}
lookup.put(type, classes);
}
return classes.toArray(Class[]::new);
Expand Down Expand Up @@ -86,8 +88,9 @@ private static void computeInterfaceOrder(Class<?>[] interfaces, Collection<Clas
newInterfaces.add(interfaze);
}
}
for (Class<?> interfaze : newInterfaces)
for (Class<?> interfaze : newInterfaces) {
computeInterfaceOrder(interfaze.getInterfaces(), classes, seen);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,11 @@ public boolean contains(Object o) {

@Override
public boolean containsAll(Collection<?> c) {
for (Object element : c)
if (!wrappedSet.contains(IdentityWrapper.wrap(element)))
for (Object element : c) {
if (!wrappedSet.contains(IdentityWrapper.wrap(element))) {
return false;
}
}
return true;
}

Expand Down Expand Up @@ -125,8 +127,9 @@ public boolean remove(Object o) {
@Override
public boolean removeAll(Collection<?> c) {
boolean changed = false;
for (Object element : c)
for (Object element : c) {
changed |= remove(element);
}
return changed;
}

Expand Down Expand Up @@ -178,10 +181,12 @@ public <T> T[] toArray(T[] a) {

@Override
public boolean equals(Object obj) {
if (obj == this)
if (obj == this) {
return true;
if (!(obj instanceof Set))
}
if (!(obj instanceof Set)) {
return false;
}
Set<?> that = (Set<?>) obj;
return size() == that.size() && containsAll(that);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,15 @@ public int hashCode() {

@Override
public boolean equals(Object obj) {
if (this == obj)
if (this == obj) {
return true;
if (obj == null)
}
if (obj == null) {
return false;
if (getClass() != obj.getClass())
}
if (getClass() != obj.getClass()) {
return false;
}
Pair other = (Pair) obj;
return Objects.equals(this.a, other.a) && Objects.equals(this.b, other.b);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ public class ValidationStatusMap extends ObservableMap<Binding, IStatus> {

private final WritableList<Binding> bindings;

private List<IObservableValue<IStatus>> dependencies = new ArrayList<>();
private final List<IObservableValue<IStatus>> dependencies = new ArrayList<>();

private IChangeListener markDirtyChangeListener = event -> markDirty();
private final IChangeListener markDirtyChangeListener = event -> markDirty();

/**
* @param realm the realm to use; not <code>null</code>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@
* @param <T> The type to which values are converted.
*/
public class AbstractStringToNumberConverter<T extends Number> extends NumberFormatConverter<Object, T> {
private Class<?> toType;
private final Class<?> toType;
/**
* NumberFormat instance to use for conversion. Access must be synchronized.
*/
private Format numberFormat;
private final Format numberFormat;

/**
* Minimum possible value for the type. Can be <code>null</code> as
Expand Down Expand Up @@ -177,23 +177,24 @@ public T convert(Object fromObject) {
}
} else if (BigInteger.class.equals(boxedType)) {
Number n = result.getNumber();
if(n instanceof Long)
if(n instanceof Long) {
return (T) BigInteger.valueOf(n.longValue());
else if(n instanceof BigInteger)
} else if(n instanceof BigInteger) {
return (T) n;
else if(n instanceof BigDecimal)
} else if(n instanceof BigDecimal) {
return (T) ((BigDecimal) n).toBigInteger();
else
} else {
return (T) BigDecimal.valueOf(n.doubleValue()).toBigInteger();
}
} else if (BigDecimal.class.equals(boxedType)) {
Number n = result.getNumber();
if(n instanceof Long)
if(n instanceof Long) {
return (T) BigDecimal.valueOf(n.longValue());
else if(n instanceof BigInteger)
} else if(n instanceof BigInteger) {
return (T) new BigDecimal((BigInteger) n);
else if(n instanceof BigDecimal)
} else if(n instanceof BigDecimal) {
return (T) n;
else if(icuBigDecimal != null && icuBigDecimal.isInstance(n)) {
} else if(icuBigDecimal != null && icuBigDecimal.isInstance(n)) {
try {
// Get ICU BigDecimal value and use to construct java.math.BigDecimal
int scale = ((Integer) icuBigDecimalScale.invoke(n)).intValue();
Expand All @@ -206,8 +207,9 @@ else if(icuBigDecimal != null && icuBigDecimal.isInstance(n)) {
}
} else if(n instanceof Double) {
BigDecimal bd = BigDecimal.valueOf(n.doubleValue());
if (bd.scale() == 0)
if (bd.scale() == 0) {
return (T) bd;
}
throw new IllegalArgumentException("Non-integral Double value returned from NumberFormat " + //$NON-NLS-1$
"which cannot be accurately stored in a BigDecimal due to lost precision. " + //$NON-NLS-1$
"Consider using ICU4J or Java 5 which can properly format and parse these types."); //$NON-NLS-1$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ private CharacterToStringConverter(boolean primitive) {
public String convert(Object fromObject) {
// Null is allowed when the type is not primitive.
if (fromObject == null) {
if (primitive)
if (primitive) {
throw new IllegalArgumentException(
"'fromObject' is null. Cannot convert to primitive char."); //$NON-NLS-1$
}
return ""; //$NON-NLS-1$
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public abstract class DateConversionSupport {
* Raw milliseconds are covered as a special case.
*/
// TODO: These could be shared, but would have to be synchronized.
private DateFormat[] formatters = {
private final DateFormat[] formatters = {
new SimpleDateFormat(BindingMessages.getString(BindingMessages.DATE_FORMAT_DATE_TIME)),
new SimpleDateFormat(BindingMessages.getString(BindingMessages.DATEFORMAT_TIME)),
DateFormat.getDateTimeInstance(DATE_FORMAT, DateFormat.SHORT),
Expand Down Expand Up @@ -102,8 +102,9 @@ protected String format(Date date) {
}

protected String format(Date date,int formatterIdx) {
if (date == null)
if (date == null) {
return null;
}
if(formatterIdx>=0) {
return formatters[formatterIdx].format(date);
}
Expand Down
Loading
Loading