/** * 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[][]{ {"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"))}}); }
/** * 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); }
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"))}}); }