@Override public <T> T getById(String id, Class<T> clazz) { return get(clazz, new LID(id)); }
@Override public void setAsText(String text) { if (Strings.isNullOrEmpty(text)) { setValue(null); } else { setValue(new LID(text)); } }
@Override public LID getLID(ID id) { STMT stmt = find(id, CORE.localId, null); String lid; if (stmt != null) { lid = stmt.getObject().getValue(); } else { lid = String.valueOf(connection.getNextLocalId()); add(id, CORE.localId, new LIT(lid)); } return new LID(lid); }
@Test public void HashCode() { LID lid2 = new LID("1"); assertEquals(lid, lid2); }
lid = (LID) id; } else { lid = new LID(id.toString());
@Test public void SetAsTextString() { editor.setAsText("1"); assertEquals(new LID("1"), editor.getValue()); }
@Test public void EqualsObject() { LID lid2 = new LID("1"); assertEquals(lid.hashCode(), lid2.hashCode()); }
@SuppressWarnings("unchecked") private Operation<?> transformPathEqNeConstant(Operation<?> operation) { Path<?> path = (Path<?>) operation.getArg(0); Constant<?> constant = (Constant<?>) operation.getArg(1); MappedPath mappedPath = getMappedPath(path); // id property if (path.getMetadata().getPathType() == PathType.PROPERTY && constant.getType().equals(String.class) && mappedPath.getPredicatePath().isEmpty()) { operation = PredicateOperation.create((Operator) operation.getOperator(), path, new ConstantImpl<ID>(session.getId(new LID(constant.toString())))); // localized property } else if (mappedPath.getMappedProperty().isLocalized()) { Locale locale; if (path.getMetadata().getPathType() == PathType.PROPERTY) { locale = session.getCurrentLocale(); } else { locale = (Locale) path.getMetadata().getElement(); } operation = PredicateOperation.create((Operator) operation.getOperator(), path, new ConstantImpl<LIT>(new LIT(constant.toString(), locale))); } return operation; }
@Test public void GetAsText() { editor.setValue(new LID("1")); assertEquals("1", editor.getAsText()); }
@Test public void Array() { MiniRepository repository = new MiniRepository(); Session session = SessionUtil.openSession(repository, ArrayTest.class); ArrayTest test = new ArrayTest(); test.array = new String[] { "a", "b", "c" }; test.numbers = new int[] { 1, 2, 3 }; session.save(test); session.clear(); ArrayTest test2 = session.get(ArrayTest.class, new LID(test.id)); assertEquals(test.id, test2.id); assertArrayEquals(test.array, test2.array); assertArrayEquals(test.numbers, test2.numbers); }