public boolean isNew(T entity) { ID id = getId(entity); Class<ID> idType = getIdType(); if (!idType.isPrimitive()) { return id == null; } if (id instanceof Number) { return ((Number) id).longValue() == 0L; } throw new IllegalArgumentException(String.format("Unsupported primitive id type %s!", idType)); }
public boolean isNew(T entity) { return getId(entity) == null; }
public GremlinSource<T> createGremlinSource() { return createGremlinSource(super.getJavaType(), idField); }
public GremlinSource<T> createGremlinSource() { return createGremlinSource(super.getJavaType(), idField); }
@Override @Nullable public ID getId(T entity) { final Field idField = this.idField; @SuppressWarnings("unchecked") final ID id = (ID) ReflectionUtils.getField(idField, entity); if (id == null && !(super.getJavaType().isAnnotationPresent(Graph.class)) && !idField.isAnnotationPresent(GeneratedValue.class)) { throw new GremlinInvalidEntityIdFieldException("A non-generated id field cannot be null!"); } return id; }
@Override @Nullable public ID getId(T entity) { final Field idField = this.idField; @SuppressWarnings("unchecked") final ID id = (ID) ReflectionUtils.getField(idField, entity); if (id == null && !(super.getJavaType().isAnnotationPresent(Graph.class)) && !idField.isAnnotationPresent(GeneratedValue.class)) { throw new GremlinInvalidEntityIdFieldException("A non-generated id field cannot be null!"); } return id; }