01 /*
02 * Copyright 2008-2014 the original author or authors.
03 *
04 * Licensed under the Apache License, Version 2.0 (the "License");
05 * you may not use this file except in compliance with the License.
06 * You may obtain a copy of the License at
07 *
08 * http://www.apache.org/licenses/LICENSE-2.0
09 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package griffon.core.artifact;
17
18 import javax.annotation.Nonnull;
19 import javax.annotation.Nullable;
20
21 /**
22 * Represents a Model class in Griffon.<p>
23 *
24 * @author Andres Almiray
25 * @since 2.0.0
26 */
27 public interface GriffonModelClass extends GriffonClass {
28 /**
29 * "model"
30 */
31 String TYPE = "model";
32 /**
33 * "Model"
34 */
35 String TRAILING = "Model";
36
37 /**
38 * Matches all public properties that are not event handlers nor
39 * have a Closure as their value.<p>
40 *
41 * @return an array containing the names of all model properties.
42 */
43 @Nonnull
44 String[] getPropertyNames();
45
46 /**
47 * Matches all public methods and closure properties whose name
48 * matches the event handler convention, i.e, starts with "on" and
49 * is followed by at least one uppercase character.<p>
50 *
51 * @return an array containing the names of all event handlers.
52 */
53 @Nonnull
54 String[] getEventNames();
55
56 /**
57 * Sets a value of a model property.
58 *
59 * @param model the model to be affected
60 * @param propertyName the name of the property to update
61 * @param value new value
62 */
63 void setModelPropertyValue(@Nonnull GriffonModel model, @Nonnull String propertyName, @Nullable Object value);
64
65 /**
66 * Returns the value of a model property.
67 *
68 * @param model the model to query
69 * @param propertyName the name of the property to query
70 * @return the value of the property
71 */
72 @Nullable
73 Object getModelPropertyValue(@Nonnull GriffonModel model, @Nonnull String propertyName);
74 }
|