@Override public boolean equals(Object o) { if ( o instanceof SyncToken ) { SyncToken other = (SyncToken)o; return CollectionUtil.equals(_value, other._value); } return false; }
/** * Takes the result of the left and right filter and ORs them. */ public OrFilter(final Filter left, final Filter right) { this(CollectionUtil.newList(left, right)); }
public OperationRequest(ConnectorKey key, String connectorFacadeKey, Class<? extends APIOperation> operation, String operationMethodName, List<Object> arguments) { connectorKey = key; configuration = connectorFacadeKey; this.operation = operation; this.operationMethodName = operationMethodName; this.arguments = CollectionUtil.newReadOnlyList(arguments); }
public HelloResponse(Throwable exception, Map<String, Object> serverInfo, List<ConnectorKey> connectorKeys, List<RemoteConnectorInfoImpl> connectorInfos) { this.exception = exception; this.serverInfo = CollectionUtil.asReadOnlyMap(serverInfo); this.connectorKeys = CollectionUtil.newReadOnlyList(connectorKeys); this.connectorInfos = CollectionUtil.newReadOnlyList(connectorInfos); }
static <E> boolean checkValue(List<E> fetchedValues, List<E> expectedValues) { Iterator<E> e = expectedValues.iterator(); List<E> fetchedValuesClone = CollectionUtil.newList(fetchedValues); while (e.hasNext()) { E expected = e.next(); boolean found = false; Iterator<E> f = fetchedValuesClone.iterator(); while (f.hasNext()) { if (CollectionUtil.equals(expected, f.next())) { f.remove(); found = true; break; } } if (!found) { return false; } } return true; }
public static <T, K> Map<T, K> newMap(T k0, K v0, T k1, K v1, T k2, K v2) { Map<T, K> map = newMap(k0, v0, k1, v1); map.put(k2, v2); return map; }
/** * Create a modifiable list from the {@link Collection} provided. The return * value is backed by an {@link ArrayList}. */ public static <T> List<T> newList(Collection<? extends T> c) { return new ArrayList<>(CollectionUtil.nullAsEmpty(c)); }
/** * {@inheritDoc} */ public Set<Class<? extends APIOperation>> getSupportedOperations() { return CollectionUtil.newReadOnlySet(_supportedOperations); }
/** * Transform a <code>Collection</code> of {@link AttributeDelta} instances * into a {@link Map}. * * The key to each element in the map is the <i>name</i> of an * <code>AttributeDelta</code>. The value of each element in the map is the * <code>AttributeDelta</code> instance with that name. * * @param attributesDelta * set of attributesDelta to transform to a map. * @return a map of string and attributesDelta. * @throws NullPointerException * if the parameter <strong>attributesDelta</strong> is * <strong>null</strong>. */ public static Map<String, AttributeDelta> toMap(final Collection<? extends AttributeDelta> attributesDelta) { final Map<String, AttributeDelta> ret = CollectionUtil.<AttributeDelta>newCaseInsensitiveMap(); for (AttributeDelta attr : attributesDelta) { ret.put(attr.getName(), attr); } return CollectionUtil.asReadOnlyMap(ret); }
/** * Transform a <code>Collection</code> of {@link AttributeInfo} instances * into a {@link Map}. The key to each element in the map is the <i>name</i> * of an <code>AttributeInfo</code>. The value of each element in the map is * the <code>AttributeInfo</code> instance with that name. * * @param attributes * set of AttributeInfo to transform to a map. * @return a map of string and AttributeInfo. * @throws NullPointerException * if the parameter <strong>attributes</strong> is * <strong>null</strong>. */ public static Map<String, AttributeInfo> toMap(Collection<? extends AttributeInfo> attributes) { Map<String, AttributeInfo> ret = CollectionUtil.<AttributeInfo> newCaseInsensitiveMap(); for (AttributeInfo attr : attributes) { ret.put(attr.getName(), attr); } return ret; }
/** * Return any current value of the attribute that is being built. * * @return any current value of the attribute that is being built. */ public List<Object> getValue() { return value == null ? null : CollectionUtil.asReadOnlyList(value); }
/** * Public only for serialization; please use {@link OperationOptionsBuilder}. * * @param operationOptions The options. */ public OperationOptions(Map<String, Object> operationOptions) { for (Object value : operationOptions.values()) { FrameworkUtil.checkOperationOptionValue(value); } // clone options to do a deep copy in case anything // is an array @SuppressWarnings("unchecked") Map<String, Object> operationOptionsClone = (Map<String, Object>) SerializerUtil.cloneObject(operationOptions); this.operationOptions = CollectionUtil.asReadOnlyMap(operationOptionsClone); }
/** * Call compareTo on the attribute values. If the attribute is not present * in the {@link ConnectorObject} return -1. */ public int compare(ConnectorObject obj) { int ret = -1; Attribute attr = obj.getAttributeByName(getName()); if (attr != null && attr.getValue().size() == 1) { // it must be a comparable because that's were testing against if (!(attr.getValue().get(0) instanceof Comparable)) { throw new IllegalArgumentException("Attribute value must be comparable!"); } // grab this value and the on from the attribute an compare.. Object o1 = attr.getValue().get(0); Object o2 = getValue(); ret = CollectionUtil.forceCompare(o1, o2); } return ret; } }
public static <T, K> Map<T, K> newMap(T k0, K v0, T k1, K v1, T k2, K v2) { Map<T, K> map = newMap(k0, v0, k1, v1); map.put(k2, v2); return map; }
/** * Creates a set that can be modified from the {@link Collection} provided. */ public static <T> Set<T> newSet(Collection<T> c) { return new HashSet<T>(CollectionUtil.nullAsEmpty(c)); }
/** * {@inheritDoc} */ @Override public Set<Class<? extends APIOperation>> getSupportedOperations() { return CollectionUtil.newReadOnlySet(supportedOperations); }
/** * Transform a <code>Collection</code> of {@link Attribute} instances into a * {@link Map}. * * The key to each element in the map is the <i>name</i> of an * <code>Attribute</code>. The value of each element in the map is the * <code>Attribute</code> instance with that name. * * @param attributes * set of attribute to transform to a map. * @return a map of string and attribute. * @throws NullPointerException * if the parameter <strong>attributes</strong> is * <strong>null</strong>. */ public static Map<String, Attribute> toMap(final Collection<? extends Attribute> attributes) { final Map<String, Attribute> ret = CollectionUtil.<Attribute> newCaseInsensitiveMap(); for (Attribute attr : attributes) { ret.put(attr.getName(), attr); } return CollectionUtil.asReadOnlyMap(ret); }
public HelloResponse(Throwable exception, Map<String, Object> serverInfo, List<ConnectorKey> connectorKeys, List<RemoteConnectorInfoImpl> connectorInfos) { this.exception = exception; this.serverInfo = CollectionUtil.asReadOnlyMap(serverInfo); this.connectorKeys = CollectionUtil.newReadOnlyList(connectorKeys); this.connectorInfos = CollectionUtil.newReadOnlyList(connectorInfos); }
/** * Transform a <code>Collection</code> of {@link AttributeInfo} instances * into a {@link Map}. The key to each element in the map is the <i>name</i> * of an <code>AttributeInfo</code>. The value of each element in the map is * the <code>AttributeInfo</code> instance with that name. * * @param attributes * set of AttributeInfo to transform to a map. * @return a map of string and AttributeInfo. * @throws NullPointerException * if the parameter <strong>attributes</strong> is * <strong>null</strong>. */ public static Map<String, AttributeInfo> toMap(Collection<? extends AttributeInfo> attributes) { Map<String, AttributeInfo> ret = CollectionUtil.<AttributeInfo> newCaseInsensitiveMap(); for (AttributeInfo attr : attributes) { ret.put(attr.getName(), attr); } return ret; }
/** * Return any current value of the attribute that is being built. * @return any current value of the attribute that is being built. */ public List<Object> getValue() { return _value == null ? null : CollectionUtil.asReadOnlyList(_value); }