/** * Create a new location with a given path and identification property. * * @param idProperty the identification property */ LocationWithProperty( Property idProperty ) { super(Collections.singletonList(idProperty)); assert idProperty != null; assert !idProperty.isEmpty(); }
/** * Create a new location with a given path and identification property. * * @param path the path * @param idProperty the identification property */ LocationWithPathAndProperty( Path path, Property idProperty ) { super(path, Collections.singletonList(idProperty)); assert idProperty != null; assert !idProperty.isEmpty(); }
/** * {@inheritDoc} * * @see Location#with(Property) */ @Override public Location with( Property newIdProperty ) { if (newIdProperty == null || newIdProperty.isEmpty()) return this; return create(path, newIdProperty); }
/** * Get the first UUID that is in one of the {@link #getIdProperties() identification properties}. * * @return the UUID for this location, or null if there is no such identification property */ @Override public UUID getUuid() { Property property = getIdProperty(ModeShapeLexicon.UUID); if (property != null && !property.isEmpty()) { Object value = property.getFirstValue(); if (value instanceof UUID) return (UUID)value; } return null; }
/** * Get the first UUID that is in one of the {@link #getIdProperties() identification properties}. * * @return the UUID for this location, or null if there is no such identification property */ public UUID getUuid() { Property property = getIdProperty(ModeShapeLexicon.UUID); if (property != null && !property.isEmpty()) { Object value = property.getFirstValue(); if (value instanceof UUID) return (UUID)value; } return null; }
/** * {@inheritDoc} * * @see Location#with(Property) */ @Override public Location with( Property newIdProperty ) { if (newIdProperty == null || newIdProperty.isEmpty()) return this; List<Property> newIdProperties; assert hasIdProperties(); newIdProperties = new ArrayList<Property>(idProperties.size() + 1); for (Property property : idProperties) { if (!newIdProperty.getName().equals(property.getName())) newIdProperties.add(property); } newIdProperties.add(newIdProperty); newIdProperties = Collections.unmodifiableList(newIdProperties); return create(newIdProperties); }
/** * {@inheritDoc} * * @see Location#with(Property) */ @Override public Location with( Property newIdProperty ) { if (newIdProperty == null || newIdProperty.isEmpty()) return this; Property idProperty = getIdProperties().get(0); // fast if (newIdProperty.getName().equals(idProperty.getName())) { return Location.create(newIdProperty); } List<Property> newIdProperties = new ArrayList<Property>(getIdProperties().size() + 1); newIdProperties.add(newIdProperty); newIdProperties.addAll(getIdProperties()); return Location.create(newIdProperties); }
/** * {@inheritDoc} * * @see Location#with(Property) */ @Override public Location with( Property newIdProperty ) { if (newIdProperty == null || newIdProperty.isEmpty()) return this; List<Property> newIdProperties; if (hasIdProperties()) { newIdProperties = new ArrayList<Property>(idProperties.size() + 1); for (Property property : idProperties) { if (!newIdProperty.getName().equals(property.getName())) newIdProperties.add(property); } newIdProperties.add(newIdProperty); newIdProperties = Collections.unmodifiableList(newIdProperties); return create(getPath(), newIdProperties); } return create(getPath(), newIdProperty); }
/** * {@inheritDoc} * * @see Location#with(Property) */ @Override public Location with( Property idProperty ) { if (idProperty == null || idProperty.isEmpty()) return this; if (ModeShapeLexicon.UUID.equals(idProperty.getName())) { if (idProperty.isSingle() && uuid.equals(idProperty.getFirstValue())) return this; return Location.create(getPath(), idProperty); } return Location.create(getPath(), getIdProperties().get(0), idProperty); }
private String getPropertyString( Property property ) { // Surround property value in double quotes so final property looks like: // color = "blue" (single valued property) // colors = ["blue", "red", "green"] (multi-valued property) StringBuilder sb = new StringBuilder(); sb.append(getContext().getValueFactories().getStringFactory().create(property.getName())); sb.append(" = "); if (property.isEmpty()) { sb.append("null"); } else if (property.isSingle()) { String valueStr = getContext().getValueFactories().getStringFactory().create(property.getValues().next()); sb.append('\"').append(valueStr).append('\"'); } else { sb.append('['); boolean first = true; for (Object value : property.getValuesAsArray()) { if (first) first = false; else sb.append(","); String valueStr = getContext().getValueFactories().getStringFactory().create(value); sb.append('\"').append(valueStr).append('\"'); } if (property.isMultiple()) sb.append(']'); } return sb.toString(); } }
/** * {@inheritDoc} * * @see Location#with(Property) */ @Override public Location with( Property newIdProperty ) { if (newIdProperty == null || newIdProperty.isEmpty()) return this; Property idProperty = getIdProperties().get(0); // fast if (newIdProperty.getName().equals(idProperty.getName())) { return Location.create(getPath(), newIdProperty); } return Location.create(getPath(), idProperty, newIdProperty); }
@Override public String getDescription() { Property property = getProperty(ModeShapeLexicon.DESCRIPTION); if (property != null && !property.isEmpty()) { return context.getValueFactories().getStringFactory().create(property.getFirstValue()); } return null; }
if (mixinTypes == null || mixinTypes.isEmpty()) { values = ModeShapeLexicon.DERIVED; } else {
if (sourceNameProperty != null && !sourceNameProperty.isEmpty()) { if (workspaceNameProperty != null && !workspaceNameProperty.isEmpty()) { if (projectionRulesProperty != null && !projectionRulesProperty.isEmpty()) { String[] projectionRuleStrs = strings.create(projectionRulesProperty.getValuesAsArray()); if (projectionRuleStrs != null && projectionRuleStrs.length != 0) { if (readOnlyProperty != null && !readOnlyProperty.isEmpty()) { readOnly = context.getValueFactories().getBooleanFactory().create(readOnlyProperty.getFirstValue());
private String stringValueOf( Node node, Name propertyName ) { Property property = node.getProperty(propertyName); if (property == null) { // Check whether the property exists with no namespace ... property = node.getProperty(context.getValueFactories().getNameFactory().create(propertyName.getLocalName())); if (property == null) return null; } if (property.isEmpty()) return null; return context.getValueFactories().getStringFactory().create(property.getFirstValue()); }
private void verifyProperty( StreamSequencerContext context, String name, Object... values ) { Property prop = context.getInputProperty(context.getValueFactories().getNameFactory().create(name)); assertThat(prop, notNullValue()); assertThat(prop.getName(), is(context.getValueFactories().getNameFactory().create(name))); assertThat(prop.isEmpty(), is(false)); assertThat(prop.size(), is(values.length)); assertThat(prop.isMultiple(), is(values.length > 1)); assertThat(prop.isSingle(), is(values.length == 1)); Iterator<?> iter = prop.getValues(); for (Object val : values) { assertThat(iter.hasNext(), is(true)); assertThat(iter.next(), is(val)); } }
if (intervalProp != null && !intervalProp.isEmpty()) { try {
if (sequencedProperty == null || sequencedProperty.isEmpty()) { String msg = RepositoryI18n.unableToFindPropertyForSequencing.text(sequencedPropertyName, input.getLocation()); throw new SequencerException(msg);
if (timeToExpire != null && !timeToExpire.isEmpty()) { long timeToCacheInMillis = longs.create(timeToExpire.getFirstValue()); defaultCachePolicy = new BasicCachePolicy(timeToCacheInMillis, TimeUnit.MILLISECONDS).getUnmodifiable();