throw Property.Exceptions.propertyValueCanNotBeNull();
/** * Determines whether the property key/value for the specified thing can be legally set. This is typically used as * a pre-condition check prior to setting a property. * * @param key the key of the property * @param value the value of the property * @throws IllegalArgumentException whether the key/value pair is legal and if not, a clear reason exception * message is provided */ public static void validateProperty(final String key, final Object value) throws IllegalArgumentException { if (null == value) throw Property.Exceptions.propertyValueCanNotBeNull(); if (null == key) throw Property.Exceptions.propertyKeyCanNotBeNull(); if (key.isEmpty()) throw Property.Exceptions.propertyKeyCanNotBeEmpty(); if (Graph.Hidden.isHidden(key)) throw Property.Exceptions.propertyKeyCanNotBeAHiddenKey(key); }
@Parameterized.Parameters(name = "expect({0})") public static Iterable<Object[]> data() { return Arrays.asList(new Object[][]{ {"providedKeyValuesMustBeAMultipleOfTwo", new Object[]{"odd", "number", "arguments"}, Element.Exceptions.providedKeyValuesMustBeAMultipleOfTwo()}, {"providedKeyValuesMustBeAMultipleOfTwo", new Object[]{"odd"}, Element.Exceptions.providedKeyValuesMustBeAMultipleOfTwo()}, {"providedKeyValuesMustHaveALegalKeyOnEvenIndices", new Object[]{"odd", "number", 123, "test"}, Element.Exceptions.providedKeyValuesMustHaveALegalKeyOnEvenIndices()}, {"propertyValueCanNotBeNull", new Object[]{"odd", null}, Property.Exceptions.propertyValueCanNotBeNull()}, {"providedKeyValuesMustHaveALegalKeyOnEvenIndices", new Object[]{null, "val"}, Element.Exceptions.providedKeyValuesMustHaveALegalKeyOnEvenIndices()}, {"propertyKeyCanNotBeEmpty", new Object[]{"", "val"}, Property.Exceptions.propertyKeyCanNotBeEmpty()}}); }
throw Property.Exceptions.propertyValueCanNotBeNull();
throw Property.Exceptions.propertyValueCanNotBeNull();
throw Property.Exceptions.propertyValueCanNotBeNull();
/** * Determines whether the property key/value for the specified thing can be legally set. This is typically used as * a pre-condition check prior to setting a property. * * @param key the key of the property * @param value the value of the property * @throws IllegalArgumentException whether the key/value pair is legal and if not, a clear reason exception * message is provided */ public static void validateProperty(final String key, final Object value) throws IllegalArgumentException { if (null == value) throw Property.Exceptions.propertyValueCanNotBeNull(); if (null == key) throw Property.Exceptions.propertyKeyCanNotBeNull(); if (key.isEmpty()) throw Property.Exceptions.propertyKeyCanNotBeEmpty(); if (Graph.Hidden.isHidden(key)) throw Property.Exceptions.propertyKeyCanNotBeAHiddenKey(key); }
/** * Determines whether a list of key/values are legal, ensuring that there are an even number of values submitted * and that the key values in the list of arguments are {@link String} or {@link org.apache.tinkerpop.gremlin.structure.Element} objects. * * @param propertyKeyValues a list of key/value pairs * @throws IllegalArgumentException if something in the pairs is illegal */ public static void legalPropertyKeyValueArray(final Object... propertyKeyValues) throws IllegalArgumentException { if (propertyKeyValues.length % 2 != 0) throw Element.Exceptions.providedKeyValuesMustBeAMultipleOfTwo(); for (int i = 0; i < propertyKeyValues.length; i = i + 2) { if (!(propertyKeyValues[i] instanceof String) && !(propertyKeyValues[i] instanceof T)) throw Element.Exceptions.providedKeyValuesMustHaveALegalKeyOnEvenIndices(); if (null == propertyKeyValues[i + 1]) { throw Property.Exceptions.propertyValueCanNotBeNull(); } } }
private <V> Property<V> property(final String key, final V value, boolean saveDocument) { if (key == null) throw Property.Exceptions.propertyKeyCanNotBeNull(); if (value == null) throw Property.Exceptions.propertyValueCanNotBeNull(); if (Graph.Hidden.isHidden(key)) throw Property.Exceptions.propertyKeyCanNotBeAHiddenKey(key); this.graph.tx().readWrite(); OElement doc = getRawElement(); doc.setProperty(key, value); // when setting multiple properties at once, it makes sense to only save // them in the end // for performance reasons and so that the schema checker only kicks in // at the end if (saveDocument) doc.save(); return new OrientProperty<>(key, value, this); }
@Parameterized.Parameters(name = "expect({0})") public static Iterable<Object[]> data() { return Arrays.asList(new Object[][]{ {"propertyValueCanNotBeNull", "k", null, Property.Exceptions.propertyValueCanNotBeNull()}, {"propertyKeyCanNotBeNull", null, "v", Property.Exceptions.propertyKeyCanNotBeNull()}, {"propertyKeyCanNotBeEmpty", "", "v", Property.Exceptions.propertyKeyCanNotBeEmpty()}, {"propertyKeyCanNotBeAHiddenKey", Graph.Hidden.hide("systemKey"), "value", Property.Exceptions.propertyKeyCanNotBeAHiddenKey(Graph.Hidden.hide("systemKey"))}}); }
@Parameterized.Parameters(name = "expect({0})") public static Iterable<Object[]> data() { return Arrays.asList(new Object[][]{ {"providedKeyValuesMustBeAMultipleOfTwo", new Object[]{"odd", "number", "arguments"}, Element.Exceptions.providedKeyValuesMustBeAMultipleOfTwo()}, {"providedKeyValuesMustBeAMultipleOfTwo", new Object[]{"odd"}, Element.Exceptions.providedKeyValuesMustBeAMultipleOfTwo()}, {"providedKeyValuesMustHaveALegalKeyOnEvenIndices", new Object[]{"odd", "number", 123, "test"}, Element.Exceptions.providedKeyValuesMustHaveALegalKeyOnEvenIndices()}, {"propertyValueCanNotBeNull", new Object[]{"odd", null}, Property.Exceptions.propertyValueCanNotBeNull()}, {"providedKeyValuesMustHaveALegalKeyOnEvenIndices", new Object[]{null, "val"}, Element.Exceptions.providedKeyValuesMustHaveALegalKeyOnEvenIndices()}, {"propertyKeyCanNotBeEmpty", new Object[]{"", "val"}, Property.Exceptions.propertyKeyCanNotBeEmpty()}}); }
/** * Determines whether a list of key/values are legal, ensuring that there are an even number of values submitted * and that the key values in the list of arguments are {@link String} or {@link org.apache.tinkerpop.gremlin.structure.Element} objects. * * @param propertyKeyValues a list of key/value pairs * @throws IllegalArgumentException if something in the pairs is illegal */ public static void legalPropertyKeyValueArray(final Object... propertyKeyValues) throws IllegalArgumentException { if (propertyKeyValues.length % 2 != 0) throw Element.Exceptions.providedKeyValuesMustBeAMultipleOfTwo(); for (int i = 0; i < propertyKeyValues.length; i = i + 2) { if (!(propertyKeyValues[i] instanceof String) && !(propertyKeyValues[i] instanceof T)) throw Element.Exceptions.providedKeyValuesMustHaveALegalKeyOnEvenIndices(); if (null == propertyKeyValues[i + 1]) { throw Property.Exceptions.propertyValueCanNotBeNull(); } } }
@Parameterized.Parameters(name = "expect({0})") public static Iterable<Object[]> data() { return Arrays.asList(new Object[][]{ {"propertyValueCanNotBeNull", "k", null, Property.Exceptions.propertyValueCanNotBeNull()}, {"propertyKeyCanNotBeNull", null, "v", Property.Exceptions.propertyKeyCanNotBeNull()}, {"propertyKeyCanNotBeEmpty", "", "v", Property.Exceptions.propertyKeyCanNotBeEmpty()}, {"propertyKeyCanNotBeAHiddenKey", Graph.Hidden.hide("systemKey"), "value", Property.Exceptions.propertyKeyCanNotBeAHiddenKey(Graph.Hidden.hide("systemKey"))}}); }