@Override @SuppressWarnings("unchecked") public <T> T getPropertyValue(String name) { Property prop = _properties.get(name); if (prop != null) { return (T) prop.getValue(); } return null; }
@Override @SuppressWarnings("unchecked") public <T> T getPropertyValue(String name) { Property property = getProperty(name); return property == null ? null : (T) property.getValue(); }
/** * {@inheritDoc} */ @Override public Collection<Object> values() { Collection<Object> values = new ArrayList<Object>(); for (Property property : getProperties(_scope)) { values.add(property.getValue()); } return values; }
/** * {@inheritDoc} */ @Override public Collection<Object> values() { Collection<Object> values = new ArrayList<Object>(); for (Property property : getProperties(_scope)) { values.add(property.getValue()); } return values; }
@Override @SuppressWarnings("unchecked") public <T> T getPropertyValue(String name) { Property property = getProperty(name); return property == null ? null : (T) property.getValue(); }
/** * {@inheritDoc} */ @Override public Collection<Object> values() { Collection<Object> values = new ArrayList<Object>(); for (Property property : getProperties(_scope)) { values.add(property.getValue()); } return values; }
@Override @SuppressWarnings("unchecked") public <T> T getPropertyValue(String name) { Property property = getProperty(name); return property == null ? null : (T) property.getValue(); }
/** * {@inheritDoc} */ @Override public Object get(Object key) { if (key != null) { Property property = getProperty(key.toString(), _scope); if (property != null) { return property.getValue(); } } return null; }
/** * {@inheritDoc} */ @Override public Object get(Object key) { if (key != null) { Property property = getProperty(key.toString(), _scope); if (property != null) { return property.getValue(); } } return null; }
@SuppressWarnings("unchecked") private static Set<Policy> getPolicies(Exchange exchange, String propertyName) { Property intentsProperty = exchange.getContext().getProperty(propertyName, Scope.EXCHANGE); Set<Policy> intents = new HashSet<Policy>(); if (intentsProperty != null) { intents.addAll((Set<Policy>)intentsProperty.getValue()); } return intents; }
/** * {@inheritDoc} */ @Override public Set<Entry<String, Object>> entrySet() { Map<String, Object> entries = new HashMap<String, Object>(); for (Property property : getProperties(_scope)) { entries.put(property.getName(), property.getValue()); } return entries.entrySet(); }
/** * {@inheritDoc} */ @Override public Set<Entry<String, Object>> entrySet() { Map<String, Object> entries = new HashMap<String, Object>(); for (Property property : getProperties(_scope)) { entries.put(property.getName(), property.getValue()); } return entries.entrySet(); }
private static TransformSequence get(final Exchange exchange) { Property sequenceProperty = exchange.getContext().getProperty(TransformSequence.class.getName()); if (sequenceProperty != null) { return (TransformSequence)sequenceProperty.getValue(); } else { return null; } } }
@Override public Context setProperties(Set<Property> properties) { for (Property property : properties) { setProperty(property.getName(), property.getValue(), property.getScope()); } return this; }
@Override public Context setProperties(Set<Property> properties) { for (Property property : properties) { Set<String> labels = property.getLabels(); setProperty(property.getName(), property.getValue(), property.getScope()) .addLabels(labels.toArray(new String[labels.size()])); } return this; }
@Override public Context setProperties(Set<Property> properties) { for (Property property : properties) { setProperty(property.getName(), property.getValue(), property.getScope()); } return this; }
@Test public void testGetProperties() { _context.setProperty(PROP_NAME, PROP_VAL); Set<Property> props = _context.getProperties(); Assert.assertTrue(props.size() == 1); Assert.assertEquals(PROP_VAL, props.iterator().next().getValue()); // operations to the returned map should *not* be reflected in the context props.remove(PROP_NAME); Assert.assertTrue(_context.getProperties().size() == 1); }
@Test public void testGetSet() { _context.setProperty(PROP_NAME, PROP_VAL); Assert.assertEquals(PROP_VAL, _context.getProperty(PROP_NAME).getValue()); }
@Override public void mergeInto(Context context) { for (Property property : getProperties()) { if (ContextPropertyUtil.isReservedProperty(property.getName(), property.getScope()) || property.hasLabel(BehaviorLabel.TRANSIENT.label())) { continue; } context.setProperty(property.getName(), property.getValue(), property.getScope()) .addLabels(property.getLabels()); } }
@Test public void testRemove() { _context.setProperty(PROP_NAME, PROP_VAL); Property p = _context.getProperty(PROP_NAME); Assert.assertEquals(PROP_VAL, p.getValue()); _context.removeProperty(p); Assert.assertNull(_context.getProperty(PROP_NAME)); }