/** * Copyright (C) 2010-2017 Structr GmbH * * This file is part of Structr <http://structr.org>. * * Structr is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * Structr is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Structr. If not, see <http://www.gnu.org/licenses/>. */ /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package org.structr.core.property; import org.structr.api.Predicate; import org.structr.api.search.SortType; import org.structr.common.SecurityContext; import org.structr.core.GraphObject; import org.structr.core.converter.PropertyConverter; import org.structr.core.entity.AbstractNode; import org.structr.core.entity.AbstractRelationship; import org.structr.core.notion.Notion; /** * * */ public class RelationshipEndNode<T extends AbstractNode> extends AbstractReadOnlyProperty<T> { private Notion notion = null; public RelationshipEndNode(String name) { this(name, null); } public RelationshipEndNode(String name, final Notion notion) { super(name); this.notion = notion; } @Override public Object fixDatabaseProperty(Object value) { return null; } @Override public String typeName() { return "Node"; } @Override public Class valueType() { return relatedType(); } @Override public Class relatedType() { return AbstractRelationship.class; } @Override public PropertyConverter<?, T> inputConverter(SecurityContext securityContext) { if (notion != null) { return notion.getEntityConverter(securityContext); } return null; } @Override public T getProperty(SecurityContext securityContext, GraphObject obj, boolean applyConverter) { return getProperty(securityContext, obj, applyConverter, null); } @Override public T getProperty(SecurityContext securityContext, GraphObject obj, boolean applyConverter, final Predicate<GraphObject> predicate) { return (T)((AbstractRelationship)obj).getTargetNode(); } @Override public boolean isCollection() { return false; } @Override public SortType getSortType() { return SortType.Default; } }