public static void checkTypeName(TitanSchemaCategory category, String name) { switch (category) { case EDGELABEL: case VERTEXLABEL: if (name == null) throw Element.Exceptions.labelCanNotBeNull(); if (StringUtils.isBlank(name)) throw Element.Exceptions.labelCanNotBeEmpty(); break; case PROPERTYKEY: if (name == null) throw Property.Exceptions.propertyKeyCanNotBeNull(); if (StringUtils.isBlank(name)) throw Property.Exceptions.propertyKeyCanNotBeEmpty(); break; case GRAPHINDEX: Preconditions.checkArgument(StringUtils.isNotBlank(name),"Index name cannot be empty: %s",name); break; default: throw new AssertionError(category); } }
public static void checkTypeName(JanusGraphSchemaCategory category, String name) { switch (category) { case EDGELABEL: case VERTEXLABEL: if (name == null) throw Element.Exceptions.labelCanNotBeNull(); if (StringUtils.isBlank(name)) throw Element.Exceptions.labelCanNotBeEmpty(); break; case PROPERTYKEY: if (name == null) throw Property.Exceptions.propertyKeyCanNotBeNull(); if (StringUtils.isBlank(name)) throw Property.Exceptions.propertyKeyCanNotBeEmpty(); break; case GRAPHINDEX: Preconditions.checkArgument(StringUtils.isNotBlank(name),"Index name cannot be empty: %s",name); break; default: throw new AssertionError(category); } }
/** * 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 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); }
public static void checkTypeName(TitanSchemaCategory category, String name) { switch (category) { case EDGELABEL: case VERTEXLABEL: if (name == null) throw Element.Exceptions.labelCanNotBeNull(); if (StringUtils.isBlank(name)) throw Element.Exceptions.labelCanNotBeEmpty(); break; case PROPERTYKEY: if (name == null) throw Property.Exceptions.propertyKeyCanNotBeNull(); if (StringUtils.isBlank(name)) throw Property.Exceptions.propertyKeyCanNotBeEmpty(); break; case GRAPHINDEX: Preconditions.checkArgument(StringUtils.isNotBlank(name),"Index name cannot be empty: %s",name); break; default: throw new AssertionError(category); } }
@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()}}); }
@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()}}); }
@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"))}}); }