001 /*
002 * Copyright 2008-2014 the original author or authors.
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 package griffon.core.mvc;
017
018 import griffon.core.artifact.GriffonController;
019 import griffon.core.artifact.GriffonModel;
020 import griffon.core.artifact.GriffonView;
021
022 import javax.annotation.Nonnull;
023 import javax.annotation.Nullable;
024 import java.util.Map;
025
026 /**
027 * Defines an MVC group and its contents
028 *
029 * @author Andres Almiray
030 * @since 2.0.0
031 */
032 public interface MVCGroup {
033 /**
034 * Returns the configuration of this group.
035 *
036 * @return the configuration used to instantiate this group.
037 */
038 @Nonnull
039 MVCGroupConfiguration getConfiguration();
040
041 /**
042 * Returns the type of this group as set in the application's configuration.
043 *
044 * @return the type of the group
045 */
046 @Nonnull
047 String getMvcType();
048
049 /**
050 * Returns the id of the group.
051 * Ids are used to uniquely identify a group instance.
052 *
053 * @return the id of this group.
054 */
055 @Nonnull
056 String getMvcId();
057
058 /**
059 * Returns the Model portion of this group.
060 *
061 * @return a GriffonModel instance if the group has a model member, null otherwise
062 * @throws IllegalStateException if the group has been destroyed already
063 */
064 @Nullable
065 GriffonModel getModel();
066
067 /**
068 * Returns the View portion of this group.
069 *
070 * @return a GriffonView instance if the group has a view member, null otherwise
071 * @throws IllegalStateException if the group has been destroyed already
072 */
073 @Nullable
074 GriffonView getView();
075
076 /**
077 * Returns the Controller portion of this group.
078 *
079 * @return a GriffonController instance if the group has a controller member, null otherwise
080 * @throws IllegalStateException if the group has been destroyed already
081 */
082 @Nullable
083 GriffonController getController();
084
085 /**
086 * Returns the specified member type.
087 *
088 * @param name the type of member to retrieve
089 * @return the selected MVC member if a match is found, null otherwise
090 * @throws IllegalStateException if the group has been destroyed already
091 */
092 @Nullable
093 Object getMember(@Nonnull String name);
094
095 /**
096 * Returns a read-only view of all instance members.
097 *
098 * @return an unmodifiable Map view of all members.
099 * @throws IllegalStateException if the group has been destroyed already
100 */
101 @Nonnull
102 Map<String, Object> getMembers();
103
104 /**
105 * Destroys the current group.
106 * <strong>Should only be called once.</strong>
107 *
108 * @throws IllegalStateException if the group has been destroyed already
109 */
110 void destroy();
111
112 /**
113 * Returns whether this group has been destroyed or not.
114 *
115 * @return true if the group has not been destroyed yet, false otherwise
116 */
117 boolean isAlive();
118 }
|