001/* 002 * (C) Copyright 2014 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * Nicolas Chapurlat <nchapurlat@nuxeo.com> 018 */ 019 020package org.nuxeo.ecm.core.api.model.resolver; 021 022import java.util.List; 023 024import org.nuxeo.ecm.core.api.model.Property; 025import org.nuxeo.ecm.core.schema.types.resolver.ObjectResolver; 026 027/** 028 * @since 7.1 029 */ 030public class PropertyObjectResolverImpl implements PropertyObjectResolver { 031 032 protected Property property; 033 034 protected ObjectResolver resolver; 035 036 public PropertyObjectResolverImpl(Property property, ObjectResolver resolver) { 037 this.property = property; 038 this.resolver = resolver; 039 } 040 041 @Override 042 public List<Class<?>> getManagedClasses() { 043 return resolver.getManagedClasses(); 044 } 045 046 @Override 047 public boolean validate() { 048 return resolver.validate(property.getValue()); 049 } 050 051 @Override 052 public boolean validate(Object context) { 053 return resolver.validate(property.getValue(), context); 054 } 055 056 @Override 057 public Object fetch() { 058 return resolver.fetch(property.getValue()); 059 } 060 061 @Override 062 public Object fetch(Object context) { 063 return resolver.fetch(property.getValue(), context); 064 } 065 066 @Override 067 public <T> T fetch(Class<T> type) { 068 return resolver.fetch(type, property.getValue()); 069 } 070 071 @Override 072 public void setObject(Object object) { 073 Object reference = resolver.getReference(object); 074 property.setValue(reference); 075 } 076 077 @Override 078 public ObjectResolver getObjectResolver() { 079 return resolver; 080 } 081 082}