1 /********************************************** 2 * Copyright (C) 2011 Lukas Laag 3 * This file is part of svgreal. 4 * 5 * svgreal is free software: you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation, either version 3 of the License, or 8 * (at your option) any later version. 9 * 10 * svgreal is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with svgreal. If not, see http://www.gnu.org/licenses/ 17 **********************************************/ 18 package org.vectomatic.svg.edit.client.model; 19 20 import org.vectomatic.svg.edit.client.command.IFactoryInstantiator; 21 22 /** 23 * Interface to abstract access to a property of a 24 * GXT ModelData model object 25 * @author laaglu 26 * @param <T> The property type 27 * @param <U> The type of the object which has this property 28 */ 29 public interface IMetadata<T, U> { 30 /** 31 * Returns the identifier of this property. 32 * @return 33 */ 34 String getName(); 35 /** 36 * Returns a human readable description of this 37 * property. 38 * @return 39 */ 40 String getDescription(); 41 /** 42 * Returns the field factory of this property. 43 * @return the field factory of this property 44 */ 45 IFieldFactory getFieldFactory(); 46 /** 47 * Returns the instantiator for the factory which will record modifications 48 * to this metadata 49 * @return the instantiator for the factory which will record modifications 50 * to this metadata 51 */ 52 IFactoryInstantiator<?> getCommandFactory(); 53 /** 54 * Returns the model category this metadata belongs to 55 * @return the model category this metadata belongs to 56 */ 57 ModelCategory<U> getCategory(); 58 /** 59 * Returns the value of this property for 60 * the specified model object. 61 * @param model The model object. 62 * @return The value of this property for the specified model object. 63 */ 64 T get(U model); 65 /** 66 * Sets the value of this property for 67 * the specified model object and returns its former value. 68 * @param model The model object. 69 * @param value The value of this property for the specified model object. 70 * @return The former value of the property. 71 */ 72 T set(U model, T value); 73 /** 74 * Removes the property from the the specified 75 * model object and returns its former value. 76 * @param model The model object. 77 * @return The former value of the property. 78 */ 79 T remove(U model); 80 /** 81 * Validates the specified metadata. 82 * @param model The model object. 83 * @param value The value of this property for the specified model object. 84 * @return null if the value is valid, or a validation error 85 * message if the value is invalid. 86 */ 87 ValidationError validate(U model, T value); 88 }