You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2012/12/05 00:41:09 UTC
[19/52] [partial] ISIS-188: consolidating isis-core
http://git-wip-us.apache.org/repos/asf/isis/blob/e4735c72/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/collections/modify/CollectionAddToFacetViaAccessor.java
----------------------------------------------------------------------
diff --git a/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/collections/modify/CollectionAddToFacetViaAccessor.java b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/collections/modify/CollectionAddToFacetViaAccessor.java
new file mode 100644
index 0000000..ddfab1e
--- /dev/null
+++ b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/collections/modify/CollectionAddToFacetViaAccessor.java
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.core.progmodel.facets.collections.modify;
+
+import java.lang.reflect.Method;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.isis.applib.DomainObjectContainer;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.adapter.ObjectDirtier;
+import org.apache.isis.core.metamodel.adapter.util.AdapterInvokeUtils;
+import org.apache.isis.core.metamodel.adapter.util.AdapterUtils;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.ImperativeFacet;
+import org.apache.isis.core.metamodel.facets.collections.modify.CollectionAddToFacetAbstract;
+
+public class CollectionAddToFacetViaAccessor extends CollectionAddToFacetAbstract implements ImperativeFacet {
+
+ private final Method method;
+ private final ObjectDirtier objectDirtier;
+
+ public CollectionAddToFacetViaAccessor(final Method method, final FacetHolder holder, final ObjectDirtier objectDirtier) {
+ super(holder);
+ this.method = method;
+ this.objectDirtier = objectDirtier;
+ }
+
+ /**
+ * Returns a singleton list of the {@link Method} provided in the
+ * constructor.
+ */
+ @Override
+ public List<Method> getMethods() {
+ return Collections.singletonList(method);
+ }
+
+ @Override
+ public boolean impliesResolve() {
+ return true;
+ }
+
+ /**
+ * Bytecode cannot automatically call
+ * {@link DomainObjectContainer#objectChanged(Object)} because cannot
+ * distinguish whether interacting with accessor to read it or to modify its
+ * contents.
+ */
+ @Override
+ public boolean impliesObjectChanged() {
+ return false;
+ }
+
+ @Override
+ public void add(final ObjectAdapter owningAdapter, final ObjectAdapter elementAdapter) {
+ @SuppressWarnings("unchecked")
+ final Collection<? super Object> collection = (Collection<? super Object>) AdapterInvokeUtils.invoke(method, owningAdapter);
+ final Object elementPojo = AdapterUtils.unwrap(elementAdapter);
+ collection.add(elementPojo);
+ getObjectDirtier().objectChanged(owningAdapter);
+ }
+
+ @Override
+ protected String toStringValues() {
+ return "method=" + method;
+ }
+
+ // /////////////////////////////////////////////////////
+ // Dependencies
+ // /////////////////////////////////////////////////////
+
+ protected ObjectDirtier getObjectDirtier() {
+ return objectDirtier;
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/e4735c72/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/collections/modify/CollectionAddToFacetViaMethod.java
----------------------------------------------------------------------
diff --git a/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/collections/modify/CollectionAddToFacetViaMethod.java b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/collections/modify/CollectionAddToFacetViaMethod.java
new file mode 100644
index 0000000..3a04676
--- /dev/null
+++ b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/collections/modify/CollectionAddToFacetViaMethod.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.core.progmodel.facets.collections.modify;
+
+import java.lang.reflect.Method;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.adapter.util.AdapterInvokeUtils;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.ImperativeFacet;
+import org.apache.isis.core.metamodel.facets.collections.modify.CollectionAddToFacetAbstract;
+
+public class CollectionAddToFacetViaMethod extends CollectionAddToFacetAbstract implements ImperativeFacet {
+
+ private final Method method;
+
+ public CollectionAddToFacetViaMethod(final Method method, final FacetHolder holder) {
+ super(holder);
+ this.method = method;
+ }
+
+ /**
+ * Returns a singleton list of the {@link Method} provided in the
+ * constructor.
+ */
+ @Override
+ public List<Method> getMethods() {
+ return Collections.singletonList(method);
+ }
+
+ @Override
+ public boolean impliesResolve() {
+ return true;
+ }
+
+ @Override
+ public boolean impliesObjectChanged() {
+ return true;
+ }
+
+ @Override
+ public void add(final ObjectAdapter owningAdapter, final ObjectAdapter elementAdapter) {
+ AdapterInvokeUtils.invoke(method, owningAdapter, elementAdapter);
+ }
+
+ @Override
+ protected String toStringValues() {
+ return "method=" + method;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/e4735c72/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/collections/modify/CollectionRemoveFromFacetViaAccessor.java
----------------------------------------------------------------------
diff --git a/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/collections/modify/CollectionRemoveFromFacetViaAccessor.java b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/collections/modify/CollectionRemoveFromFacetViaAccessor.java
new file mode 100644
index 0000000..612d4aa
--- /dev/null
+++ b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/collections/modify/CollectionRemoveFromFacetViaAccessor.java
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.core.progmodel.facets.collections.modify;
+
+import java.lang.reflect.Method;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.isis.applib.DomainObjectContainer;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.adapter.ObjectDirtier;
+import org.apache.isis.core.metamodel.adapter.util.AdapterInvokeUtils;
+import org.apache.isis.core.metamodel.adapter.util.AdapterUtils;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.ImperativeFacet;
+import org.apache.isis.core.metamodel.facets.collections.modify.CollectionRemoveFromFacetAbstract;
+
+public class CollectionRemoveFromFacetViaAccessor extends CollectionRemoveFromFacetAbstract implements ImperativeFacet {
+
+ private final Method method;
+ private final ObjectDirtier objectDirtier;
+
+ public CollectionRemoveFromFacetViaAccessor(final Method method, final FacetHolder holder, final ObjectDirtier objectDirtier) {
+ super(holder);
+ this.method = method;
+ this.objectDirtier = objectDirtier;
+ }
+
+ /**
+ * Returns a singleton list of the {@link Method} provided in the
+ * constructor.
+ */
+ @Override
+ public List<Method> getMethods() {
+ return Collections.singletonList(method);
+ }
+
+ @Override
+ public boolean impliesResolve() {
+ return true;
+ }
+
+ /**
+ * Bytecode cannot automatically call
+ * {@link DomainObjectContainer#objectChanged(Object)} because cannot
+ * distinguish whether interacting with accessor to read it or to modify its
+ * contents.
+ */
+ @Override
+ public boolean impliesObjectChanged() {
+ return false;
+ }
+
+ @Override
+ public void remove(final ObjectAdapter owningAdapter, final ObjectAdapter elementAdapter) {
+ @SuppressWarnings("unchecked")
+ final Collection<? super Object> collection = (Collection<? super Object>) AdapterInvokeUtils.invoke(method, owningAdapter);
+ collection.remove(AdapterUtils.unwrap(elementAdapter));
+ getObjectDirtier().objectChanged(owningAdapter);
+ }
+
+ @Override
+ protected String toStringValues() {
+ return "method=" + method;
+ }
+
+ // /////////////////////////////////////////////////////////
+ // Dependencies (from constructor)
+ // /////////////////////////////////////////////////////////
+
+ protected ObjectDirtier getObjectDirtier() {
+ return objectDirtier;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/e4735c72/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/collections/modify/CollectionRemoveFromFacetViaMethod.java
----------------------------------------------------------------------
diff --git a/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/collections/modify/CollectionRemoveFromFacetViaMethod.java b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/collections/modify/CollectionRemoveFromFacetViaMethod.java
new file mode 100644
index 0000000..9fbda42
--- /dev/null
+++ b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/collections/modify/CollectionRemoveFromFacetViaMethod.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.core.progmodel.facets.collections.modify;
+
+import java.lang.reflect.Method;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.adapter.util.AdapterInvokeUtils;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.ImperativeFacet;
+import org.apache.isis.core.metamodel.facets.collections.modify.CollectionRemoveFromFacetAbstract;
+
+public class CollectionRemoveFromFacetViaMethod extends CollectionRemoveFromFacetAbstract implements ImperativeFacet {
+
+ private final Method method;
+
+ public CollectionRemoveFromFacetViaMethod(final Method method, final FacetHolder holder) {
+ super(holder);
+ this.method = method;
+ }
+
+ /**
+ * Returns a singleton list of the {@link Method} provided in the
+ * constructor.
+ */
+ @Override
+ public List<Method> getMethods() {
+ return Collections.singletonList(method);
+ }
+
+ @Override
+ public boolean impliesResolve() {
+ return true;
+ }
+
+ @Override
+ public boolean impliesObjectChanged() {
+ return true;
+ }
+
+ @Override
+ public void remove(final ObjectAdapter owningAdapter, final ObjectAdapter elementAdapter) {
+ AdapterInvokeUtils.invoke(method, owningAdapter, elementAdapter);
+ }
+
+ @Override
+ protected String toStringValues() {
+ return "method=" + method;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/e4735c72/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/collections/modify/TypeOfFacetInferredFromSupportingMethods.java
----------------------------------------------------------------------
diff --git a/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/collections/modify/TypeOfFacetInferredFromSupportingMethods.java b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/collections/modify/TypeOfFacetInferredFromSupportingMethods.java
new file mode 100644
index 0000000..00fe673
--- /dev/null
+++ b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/collections/modify/TypeOfFacetInferredFromSupportingMethods.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.core.progmodel.facets.collections.modify;
+
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.typeof.TypeOfFacetAbstract;
+import org.apache.isis.core.metamodel.spec.SpecificationLoader;
+
+public class TypeOfFacetInferredFromSupportingMethods extends TypeOfFacetAbstract {
+
+ public TypeOfFacetInferredFromSupportingMethods(final Class<?> type, final FacetHolder holder, final SpecificationLoader specificationLookup) {
+ super(type, holder, specificationLookup);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/e4735c72/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/collections/notpersisted/annotation/NotPersistedAnnotationForCollectionFacetFactory.java
----------------------------------------------------------------------
diff --git a/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/collections/notpersisted/annotation/NotPersistedAnnotationForCollectionFacetFactory.java b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/collections/notpersisted/annotation/NotPersistedAnnotationForCollectionFacetFactory.java
new file mode 100644
index 0000000..9c25acb
--- /dev/null
+++ b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/collections/notpersisted/annotation/NotPersistedAnnotationForCollectionFacetFactory.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.core.progmodel.facets.collections.notpersisted.annotation;
+
+import org.apache.isis.applib.annotation.NotPersisted;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facetapi.FacetUtil;
+import org.apache.isis.core.metamodel.facetapi.FeatureType;
+import org.apache.isis.core.metamodel.facets.Annotations;
+import org.apache.isis.core.metamodel.facets.FacetFactoryAbstract;
+import org.apache.isis.core.metamodel.facets.notpersisted.NotPersistedFacet;
+
+public class NotPersistedAnnotationForCollectionFacetFactory extends FacetFactoryAbstract {
+
+ public NotPersistedAnnotationForCollectionFacetFactory() {
+ super(FeatureType.COLLECTIONS_ONLY);
+ }
+
+ @Override
+ public void process(final ProcessMethodContext processMethodContext) {
+ final NotPersisted annotation = Annotations.getAnnotation(processMethodContext.getMethod(), NotPersisted.class);
+ FacetUtil.addFacet(create(annotation, processMethodContext.getFacetHolder()));
+ }
+
+ private NotPersistedFacet create(final NotPersisted annotation, final FacetHolder holder) {
+ return annotation == null ? null : new NotPersistedFacetAnnotationForCollection(holder);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/e4735c72/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/collections/notpersisted/annotation/NotPersistedFacetAnnotationForCollection.java
----------------------------------------------------------------------
diff --git a/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/collections/notpersisted/annotation/NotPersistedFacetAnnotationForCollection.java b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/collections/notpersisted/annotation/NotPersistedFacetAnnotationForCollection.java
new file mode 100644
index 0000000..8dc876b
--- /dev/null
+++ b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/collections/notpersisted/annotation/NotPersistedFacetAnnotationForCollection.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.core.progmodel.facets.collections.notpersisted.annotation;
+
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.notpersisted.NotPersistedFacetAbstract;
+
+public class NotPersistedFacetAnnotationForCollection extends NotPersistedFacetAbstract {
+
+ public NotPersistedFacetAnnotationForCollection(final FacetHolder holder) {
+ super(holder);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/e4735c72/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/collections/typeof/TypeOfAnnotationForCollectionsFacetFactory.java
----------------------------------------------------------------------
diff --git a/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/collections/typeof/TypeOfAnnotationForCollectionsFacetFactory.java b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/collections/typeof/TypeOfAnnotationForCollectionsFacetFactory.java
new file mode 100644
index 0000000..d330187
--- /dev/null
+++ b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/collections/typeof/TypeOfAnnotationForCollectionsFacetFactory.java
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.core.progmodel.facets.collections.typeof;
+
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.lang.reflect.TypeVariable;
+
+import org.apache.isis.applib.annotation.TypeOf;
+import org.apache.isis.core.metamodel.facetapi.FacetUtil;
+import org.apache.isis.core.metamodel.facetapi.FeatureType;
+import org.apache.isis.core.metamodel.facets.Annotations;
+import org.apache.isis.core.metamodel.facets.FacetFactoryAbstract;
+import org.apache.isis.core.metamodel.facets.typeof.TypeOfFacetInferredFromArray;
+import org.apache.isis.core.metamodel.facets.typeof.TypeOfFacetInferredFromGenerics;
+import org.apache.isis.core.metamodel.specloader.collectiontyperegistry.CollectionTypeRegistry;
+import org.apache.isis.core.metamodel.specloader.collectiontyperegistry.CollectionTypeRegistryAware;
+
+public class TypeOfAnnotationForCollectionsFacetFactory extends FacetFactoryAbstract implements CollectionTypeRegistryAware {
+ private CollectionTypeRegistry collectionTypeRegistry;
+
+ public TypeOfAnnotationForCollectionsFacetFactory() {
+ super(FeatureType.COLLECTIONS_ONLY);
+ }
+
+ @Override
+ public void process(final ProcessMethodContext processMethodContext) {
+
+ final TypeOf annotation = Annotations.getAnnotation(processMethodContext.getMethod(), TypeOf.class);
+
+ final Class<?> methodReturnType = processMethodContext.getMethod().getReturnType();
+ if (!collectionTypeRegistry.isCollectionType(methodReturnType) && !collectionTypeRegistry.isArrayType(methodReturnType)) {
+ return;
+ }
+
+ final Class<?> returnType = processMethodContext.getMethod().getReturnType();
+ if (returnType.isArray()) {
+ final Class<?> componentType = returnType.getComponentType();
+ FacetUtil.addFacet(new TypeOfFacetInferredFromArray(componentType, processMethodContext.getFacetHolder(), getSpecificationLoader()));
+ return;
+ }
+
+ if (annotation != null) {
+ FacetUtil.addFacet(new TypeOfFacetAnnotationForCollection(annotation.value(), processMethodContext.getFacetHolder(), getSpecificationLoader()));
+ return;
+ }
+
+ final Type type = processMethodContext.getMethod().getGenericReturnType();
+ if (!(type instanceof ParameterizedType)) {
+ return;
+ }
+
+ final ParameterizedType parameterizedType = (ParameterizedType) type;
+ final Type[] actualTypeArguments = parameterizedType.getActualTypeArguments();
+ if (actualTypeArguments.length == 0) {
+ return;
+ }
+
+ final Object actualTypeArgument = actualTypeArguments[0];
+ if (actualTypeArgument instanceof Class) {
+ final Class<?> actualType = (Class<?>) actualTypeArgument;
+ FacetUtil.addFacet(new TypeOfFacetInferredFromGenerics(actualType, processMethodContext.getFacetHolder(), getSpecificationLoader()));
+ return;
+ }
+
+ if (actualTypeArgument instanceof TypeVariable) {
+
+ // TODO: what to do here?
+ return;
+ }
+
+ }
+
+ @Override
+ public void setCollectionTypeRegistry(final CollectionTypeRegistry collectionTypeRegistry) {
+ this.collectionTypeRegistry = collectionTypeRegistry;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/e4735c72/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/collections/typeof/TypeOfFacetAnnotationForCollection.java
----------------------------------------------------------------------
diff --git a/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/collections/typeof/TypeOfFacetAnnotationForCollection.java b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/collections/typeof/TypeOfFacetAnnotationForCollection.java
new file mode 100644
index 0000000..1fd9e64
--- /dev/null
+++ b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/collections/typeof/TypeOfFacetAnnotationForCollection.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.core.progmodel.facets.collections.typeof;
+
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.typeof.TypeOfFacetAbstract;
+import org.apache.isis.core.metamodel.spec.SpecificationLoader;
+
+public class TypeOfFacetAnnotationForCollection extends TypeOfFacetAbstract {
+
+ public TypeOfFacetAnnotationForCollection(final Class<?> type, final FacetHolder holder, final SpecificationLoader specificationLookup) {
+ super(type, holder, specificationLookup);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/e4735c72/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/collections/validate/CollectionValidateAddToFacet.java
----------------------------------------------------------------------
diff --git a/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/collections/validate/CollectionValidateAddToFacet.java b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/collections/validate/CollectionValidateAddToFacet.java
new file mode 100644
index 0000000..b744a82
--- /dev/null
+++ b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/collections/validate/CollectionValidateAddToFacet.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.core.progmodel.facets.collections.validate;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.facetapi.Facet;
+import org.apache.isis.core.metamodel.interactions.ValidatingInteractionAdvisor;
+
+/**
+ * Validate that an object can be added to a collection.
+ *
+ * <p>
+ * In the standard Apache Isis Programming Model, corresponds to invoking the
+ * <tt>validateAddToXxx</tt> support method for a collection.
+ *
+ */
+public interface CollectionValidateAddToFacet extends Facet, ValidatingInteractionAdvisor {
+
+ /**
+ * Reason the object cannot be added, or <tt>null</tt> if okay.
+ */
+ public String invalidReason(ObjectAdapter target, ObjectAdapter proposedArgument);
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/e4735c72/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/collections/validate/CollectionValidateAddToFacetAbstract.java
----------------------------------------------------------------------
diff --git a/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/collections/validate/CollectionValidateAddToFacetAbstract.java b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/collections/validate/CollectionValidateAddToFacetAbstract.java
new file mode 100644
index 0000000..f11fb61
--- /dev/null
+++ b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/collections/validate/CollectionValidateAddToFacetAbstract.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.core.progmodel.facets.collections.validate;
+
+import org.apache.isis.applib.events.ValidityEvent;
+import org.apache.isis.core.metamodel.facetapi.Facet;
+import org.apache.isis.core.metamodel.facetapi.FacetAbstract;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.interactions.CollectionAddToContext;
+import org.apache.isis.core.metamodel.interactions.ValidityContext;
+
+public abstract class CollectionValidateAddToFacetAbstract extends FacetAbstract implements CollectionValidateAddToFacet {
+
+ public static Class<? extends Facet> type() {
+ return CollectionValidateAddToFacet.class;
+ }
+
+ public CollectionValidateAddToFacetAbstract(final FacetHolder holder) {
+ super(type(), holder, Derivation.NOT_DERIVED);
+ }
+
+ @Override
+ public String invalidates(final ValidityContext<? extends ValidityEvent> context) {
+ if (!(context instanceof CollectionAddToContext)) {
+ return null;
+ }
+ final CollectionAddToContext collectionAddToContext = (CollectionAddToContext) context;
+ return invalidReason(context.getTarget(), collectionAddToContext.getProposed());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/e4735c72/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/collections/validate/CollectionValidateAddToFacetViaMethod.java
----------------------------------------------------------------------
diff --git a/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/collections/validate/CollectionValidateAddToFacetViaMethod.java b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/collections/validate/CollectionValidateAddToFacetViaMethod.java
new file mode 100644
index 0000000..f4d0cca
--- /dev/null
+++ b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/collections/validate/CollectionValidateAddToFacetViaMethod.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.core.progmodel.facets.collections.validate;
+
+import java.lang.reflect.Method;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.adapter.util.AdapterInvokeUtils;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.ImperativeFacet;
+
+public class CollectionValidateAddToFacetViaMethod extends CollectionValidateAddToFacetAbstract implements ImperativeFacet {
+
+ private final Method method;
+
+ public CollectionValidateAddToFacetViaMethod(final Method method, final FacetHolder holder) {
+ super(holder);
+ this.method = method;
+ }
+
+ /**
+ * Returns a singleton list of the {@link Method} provided in the
+ * constructor.
+ */
+ @Override
+ public List<Method> getMethods() {
+ return Collections.singletonList(method);
+ }
+
+ @Override
+ public boolean impliesResolve() {
+ return true;
+ }
+
+ @Override
+ public boolean impliesObjectChanged() {
+ return false;
+ }
+
+ @Override
+ public String invalidReason(final ObjectAdapter owningAdapter, final ObjectAdapter proposedAdapter) {
+ return (String) AdapterInvokeUtils.invoke(method, owningAdapter, proposedAdapter);
+ }
+
+ @Override
+ protected String toStringValues() {
+ return "method=" + method;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/e4735c72/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/collections/validate/CollectionValidateRemoveFromFacet.java
----------------------------------------------------------------------
diff --git a/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/collections/validate/CollectionValidateRemoveFromFacet.java b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/collections/validate/CollectionValidateRemoveFromFacet.java
new file mode 100644
index 0000000..08ca7fe
--- /dev/null
+++ b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/collections/validate/CollectionValidateRemoveFromFacet.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.core.progmodel.facets.collections.validate;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.facetapi.Facet;
+import org.apache.isis.core.metamodel.interactions.ValidatingInteractionAdvisor;
+
+/**
+ * Validate that an object can be removed to a collection.
+ *
+ * <p>
+ * In the standard Apache Isis Programming Model, corresponds to invoking the
+ * <tt>validateRemoveFromXxx</tt> support method for a collection.
+ */
+public interface CollectionValidateRemoveFromFacet extends Facet, ValidatingInteractionAdvisor {
+
+ /**
+ * Reason the object cannot be removed, or <tt>null</tt> if okay.
+ */
+ public String invalidReason(ObjectAdapter inObject, ObjectAdapter value);
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/e4735c72/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/collections/validate/CollectionValidateRemoveFromFacetAbstract.java
----------------------------------------------------------------------
diff --git a/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/collections/validate/CollectionValidateRemoveFromFacetAbstract.java b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/collections/validate/CollectionValidateRemoveFromFacetAbstract.java
new file mode 100644
index 0000000..98b0634
--- /dev/null
+++ b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/collections/validate/CollectionValidateRemoveFromFacetAbstract.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.core.progmodel.facets.collections.validate;
+
+import org.apache.isis.applib.events.ValidityEvent;
+import org.apache.isis.core.metamodel.facetapi.Facet;
+import org.apache.isis.core.metamodel.facetapi.FacetAbstract;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.interactions.CollectionRemoveFromContext;
+import org.apache.isis.core.metamodel.interactions.ValidityContext;
+
+public abstract class CollectionValidateRemoveFromFacetAbstract extends FacetAbstract implements CollectionValidateRemoveFromFacet {
+
+ public static Class<? extends Facet> type() {
+ return CollectionValidateRemoveFromFacet.class;
+ }
+
+ public CollectionValidateRemoveFromFacetAbstract(final FacetHolder holder) {
+ super(type(), holder, Derivation.NOT_DERIVED);
+ }
+
+ @Override
+ public String invalidates(final ValidityContext<? extends ValidityEvent> context) {
+ if (!(context instanceof CollectionRemoveFromContext)) {
+ return null;
+ }
+ final CollectionRemoveFromContext collectionRemoveFromContext = (CollectionRemoveFromContext) context;
+ return invalidReason(context.getTarget(), collectionRemoveFromContext.getProposed());
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/e4735c72/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/collections/validate/CollectionValidateRemoveFromFacetViaMethod.java
----------------------------------------------------------------------
diff --git a/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/collections/validate/CollectionValidateRemoveFromFacetViaMethod.java b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/collections/validate/CollectionValidateRemoveFromFacetViaMethod.java
new file mode 100644
index 0000000..7a4a213
--- /dev/null
+++ b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/collections/validate/CollectionValidateRemoveFromFacetViaMethod.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.core.progmodel.facets.collections.validate;
+
+import java.lang.reflect.Method;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.adapter.util.AdapterInvokeUtils;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.ImperativeFacet;
+
+public class CollectionValidateRemoveFromFacetViaMethod extends CollectionValidateRemoveFromFacetAbstract implements ImperativeFacet {
+
+ private final Method method;
+
+ public CollectionValidateRemoveFromFacetViaMethod(final Method method, final FacetHolder holder) {
+ super(holder);
+ this.method = method;
+ }
+
+ /**
+ * Returns a singleton list of the {@link Method} provided in the
+ * constructor.
+ */
+ @Override
+ public List<Method> getMethods() {
+ return Collections.singletonList(method);
+ }
+
+ @Override
+ public boolean impliesResolve() {
+ return true;
+ }
+
+ @Override
+ public boolean impliesObjectChanged() {
+ return false;
+ }
+
+ @Override
+ public String invalidReason(final ObjectAdapter owningAdapter, final ObjectAdapter proposedAdapter) {
+ return (String) AdapterInvokeUtils.invoke(method, owningAdapter, proposedAdapter);
+ }
+
+ @Override
+ protected String toStringValues() {
+ return "method=" + method;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/e4735c72/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/fallback/ActionChoicesFacetNone.java
----------------------------------------------------------------------
diff --git a/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/fallback/ActionChoicesFacetNone.java b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/fallback/ActionChoicesFacetNone.java
new file mode 100644
index 0000000..1d1e66f
--- /dev/null
+++ b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/fallback/ActionChoicesFacetNone.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.core.progmodel.facets.fallback;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.actions.choices.ActionChoicesFacetAbstract;
+
+public class ActionChoicesFacetNone extends ActionChoicesFacetAbstract {
+
+ public ActionChoicesFacetNone(final FacetHolder holder) {
+ super(holder);
+ }
+
+ @Override
+ public Object[][] getChoices(final ObjectAdapter inObject) {
+ return new ObjectAdapter[0][0];
+ }
+
+ @Override
+ public boolean isNoop() {
+ return true;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/e4735c72/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/fallback/ActionDefaultsFacetNone.java
----------------------------------------------------------------------
diff --git a/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/fallback/ActionDefaultsFacetNone.java b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/fallback/ActionDefaultsFacetNone.java
new file mode 100644
index 0000000..42e04e2
--- /dev/null
+++ b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/fallback/ActionDefaultsFacetNone.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.core.progmodel.facets.fallback;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.actions.defaults.ActionDefaultsFacetAbstract;
+
+public class ActionDefaultsFacetNone extends ActionDefaultsFacetAbstract {
+
+ public ActionDefaultsFacetNone(final FacetHolder holder) {
+ super(holder, Derivation.NOT_DERIVED);
+ }
+
+ @Override
+ public Object[] getDefaults(final ObjectAdapter inObject) {
+ return null;
+ }
+
+ @Override
+ public boolean isNoop() {
+ return true;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/e4735c72/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/fallback/DescribedAsFacetNone.java
----------------------------------------------------------------------
diff --git a/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/fallback/DescribedAsFacetNone.java b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/fallback/DescribedAsFacetNone.java
new file mode 100644
index 0000000..b7d2349
--- /dev/null
+++ b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/fallback/DescribedAsFacetNone.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.core.progmodel.facets.fallback;
+
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.describedas.DescribedAsFacetAbstract;
+
+/**
+ * Has a description of the empty string.
+ */
+public class DescribedAsFacetNone extends DescribedAsFacetAbstract {
+
+ public DescribedAsFacetNone(final FacetHolder holder) {
+ super("", holder);
+ }
+
+ @Override
+ public boolean isNoop() {
+ return true;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/e4735c72/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/fallback/FallbackFacetFactory.java
----------------------------------------------------------------------
diff --git a/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/fallback/FallbackFacetFactory.java b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/fallback/FallbackFacetFactory.java
new file mode 100644
index 0000000..b7b1c99
--- /dev/null
+++ b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/fallback/FallbackFacetFactory.java
@@ -0,0 +1,148 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.core.progmodel.facets.fallback;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.isis.core.commons.config.IsisConfiguration;
+import org.apache.isis.core.commons.config.IsisConfigurationAware;
+import org.apache.isis.core.metamodel.facetapi.Facet;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facetapi.FacetUtil;
+import org.apache.isis.core.metamodel.facetapi.FeatureType;
+import org.apache.isis.core.metamodel.facets.FacetFactoryAbstract;
+import org.apache.isis.core.metamodel.facets.FacetedMethod;
+import org.apache.isis.core.metamodel.facets.TypedHolder;
+
+/**
+ * Central point for providing some kind of default for any {@link Facet}s
+ * required by the Apache Isis framework itself.
+ *
+ */
+public class FallbackFacetFactory extends FacetFactoryAbstract implements IsisConfigurationAware {
+
+ public final static int PAGE_SIZE_STANDALONE_DEFAULT = 25;
+ public final static int PAGE_SIZE_PARENTED_DEFAULT = 12;
+
+ private IsisConfiguration configuration;
+
+ @SuppressWarnings("unused")
+ private final static Map<Class<?>, Integer> TYPICAL_LENGTHS_BY_CLASS = new HashMap<Class<?>, Integer>() {
+ private static final long serialVersionUID = 1L;
+ {
+ putTypicalLength(byte.class, Byte.class, 3);
+ putTypicalLength(short.class, Short.class, 5);
+ putTypicalLength(int.class, Integer.class, 10);
+ putTypicalLength(long.class, Long.class, 20);
+ putTypicalLength(float.class, Float.class, 20);
+ putTypicalLength(double.class, Double.class, 20);
+ putTypicalLength(char.class, Character.class, 1);
+ putTypicalLength(boolean.class, Boolean.class, 1);
+ }
+
+ private void putTypicalLength(final Class<?> primitiveClass, final Class<?> wrapperClass, final int length) {
+ put(primitiveClass, Integer.valueOf(length));
+ put(wrapperClass, Integer.valueOf(length));
+ }
+ };
+
+ public FallbackFacetFactory() {
+ super(FeatureType.EVERYTHING);
+ }
+
+ public boolean recognizes(final Method method) {
+ return false;
+ }
+
+ @Override
+ public void process(final ProcessClassContext processClassContaxt) {
+ final FacetHolder facetHolder = processClassContaxt.getFacetHolder();
+
+ final DescribedAsFacetNone describedAsFacet = new DescribedAsFacetNone(facetHolder);
+ final NotPersistableFacetNull notPersistableFacet = new NotPersistableFacetNull(facetHolder);
+ final TitleFacetNone titleFacet = new TitleFacetNone(facetHolder);
+ final PagedFacetDefault pagedFacet = new PagedFacetDefault(facetHolder, getConfiguration().getInteger("isis.viewers.paged.standalone", PAGE_SIZE_STANDALONE_DEFAULT));
+
+ final Facet[] facets = new Facet[] { describedAsFacet,
+ // commenting these out, think this whole isNoop business is a little bogus
+ // new ImmutableFacetNever(holder),
+ notPersistableFacet, titleFacet, pagedFacet};
+ FacetUtil.addFacets(facets);
+ }
+
+ @Override
+ public void process(final ProcessMethodContext processMethodContext) {
+ final List<Facet> facets = new ArrayList<Facet>();
+
+ final FacetedMethod facetedMethod = processMethodContext.getFacetHolder();
+
+
+ facets.add(new NamedFacetNone(facetedMethod));
+ facets.add(new DescribedAsFacetNone(facetedMethod));
+ facets.add(new HelpFacetNone(facetedMethod));
+
+
+ final FeatureType featureType = facetedMethod.getFeatureType();
+ if (featureType.isProperty()) {
+ facets.add(new MaxLengthFacetUnlimited(facetedMethod));
+ facets.add(new MultiLineFacetNone(true, facetedMethod));
+ }
+ if (featureType.isAction()) {
+ facets.add(new ActionDefaultsFacetNone(facetedMethod));
+ facets.add(new ActionChoicesFacetNone(facetedMethod));
+ }
+ if (featureType.isCollection()) {
+ facets.add(new PagedFacetDefault(facetedMethod, getConfiguration().getInteger("isis.viewers.paged.parented", PAGE_SIZE_PARENTED_DEFAULT)));
+ }
+
+ FacetUtil.addFacets(facets);
+ }
+
+ @Override
+ public void processParams(final ProcessParameterContext processParameterContext) {
+ final List<Facet> facets = new ArrayList<Facet>();
+
+ final TypedHolder typedHolder = processParameterContext.getFacetHolder();
+ if (typedHolder.getFeatureType().isActionParameter()) {
+ facets.add(new NamedFacetNone(typedHolder));
+ facets.add(new DescribedAsFacetNone(typedHolder));
+ facets.add(new HelpFacetNone(typedHolder));
+ facets.add(new MultiLineFacetNone(false, typedHolder));
+
+ facets.add(new MaxLengthFacetUnlimited(typedHolder));
+ }
+
+ FacetUtil.addFacets(facets);
+ }
+
+ @Override
+ public void setConfiguration(IsisConfiguration configuration) {
+ this.configuration = configuration;
+ }
+
+ public IsisConfiguration getConfiguration() {
+ return configuration;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/e4735c72/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/fallback/HelpFacetNone.java
----------------------------------------------------------------------
diff --git a/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/fallback/HelpFacetNone.java b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/fallback/HelpFacetNone.java
new file mode 100644
index 0000000..c040be5
--- /dev/null
+++ b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/fallback/HelpFacetNone.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.core.progmodel.facets.fallback;
+
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.help.HelpFacetAbstract;
+
+/**
+ * Has a description of <tt>null</tt>.
+ */
+public class HelpFacetNone extends HelpFacetAbstract {
+
+ public HelpFacetNone(final FacetHolder holder) {
+ super(null, holder);
+ }
+
+ @Override
+ public String value() {
+ return "No help available";
+ }
+
+ @Override
+ public boolean isNoop() {
+ return true;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/e4735c72/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/fallback/MaxLengthFacetUnlimited.java
----------------------------------------------------------------------
diff --git a/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/fallback/MaxLengthFacetUnlimited.java b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/fallback/MaxLengthFacetUnlimited.java
new file mode 100644
index 0000000..28e9da0
--- /dev/null
+++ b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/fallback/MaxLengthFacetUnlimited.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.core.progmodel.facets.fallback;
+
+import org.apache.isis.applib.events.ValidityEvent;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.maxlen.MaxLengthFacetAbstract;
+import org.apache.isis.core.metamodel.interactions.ValidityContext;
+
+public class MaxLengthFacetUnlimited extends MaxLengthFacetAbstract {
+
+ public MaxLengthFacetUnlimited(final FacetHolder holder) {
+ super(Integer.MAX_VALUE, holder);
+ }
+
+ /**
+ * No limit to maximum length.
+ */
+ @Override
+ public String invalidates(final ValidityContext<? extends ValidityEvent> context) {
+ return null;
+ }
+
+ @Override
+ public boolean isNoop() {
+ return true;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/e4735c72/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/fallback/MultiLineFacetNone.java
----------------------------------------------------------------------
diff --git a/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/fallback/MultiLineFacetNone.java b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/fallback/MultiLineFacetNone.java
new file mode 100644
index 0000000..99da077
--- /dev/null
+++ b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/fallback/MultiLineFacetNone.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.core.progmodel.facets.fallback;
+
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.multiline.MultiLineFacetAbstract;
+
+public class MultiLineFacetNone extends MultiLineFacetAbstract {
+
+ public MultiLineFacetNone(final boolean preventWrapping, final FacetHolder holder) {
+ super(1, preventWrapping, holder);
+ }
+
+ @Override
+ public boolean isNoop() {
+ return true;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/e4735c72/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/fallback/NamedFacetNone.java
----------------------------------------------------------------------
diff --git a/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/fallback/NamedFacetNone.java b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/fallback/NamedFacetNone.java
new file mode 100644
index 0000000..4e71261
--- /dev/null
+++ b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/fallback/NamedFacetNone.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.core.progmodel.facets.fallback;
+
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.named.NamedFacetAbstract;
+
+/**
+ * Has a name of <tt>null</tt>.
+ *
+ * <p>
+ * TODO: should this instead be the empty string?
+ */
+public class NamedFacetNone extends NamedFacetAbstract {
+
+ public NamedFacetNone(final FacetHolder holder) {
+ super(null, holder);
+ }
+
+ @Override
+ public boolean isNoop() {
+ return true;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/e4735c72/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/fallback/NotPersistableFacetNull.java
----------------------------------------------------------------------
diff --git a/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/fallback/NotPersistableFacetNull.java b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/fallback/NotPersistableFacetNull.java
new file mode 100644
index 0000000..b43cff4
--- /dev/null
+++ b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/fallback/NotPersistableFacetNull.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.core.progmodel.facets.fallback;
+
+import org.apache.isis.applib.events.UsabilityEvent;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.object.notpersistable.NotPersistableFacet;
+import org.apache.isis.core.metamodel.facets.object.notpersistable.NotPersistableFacetAbstract;
+import org.apache.isis.core.metamodel.interactions.UsabilityContext;
+
+/**
+ * Installed by the {@link FallbackFacetFactory}, and means that this class
+ * <i>is</i> persistable (ie not {@link NotPersistableFacet not persistable}).
+ */
+public class NotPersistableFacetNull extends NotPersistableFacetAbstract {
+
+ public NotPersistableFacetNull(final FacetHolder holder) {
+ super(null, holder);
+ }
+
+ /**
+ * Always returns <tt>null</tt> (that is, does <i>not</i> disable).
+ */
+ @Override
+ public String disables(final UsabilityContext<? extends UsabilityEvent> ic) {
+ return null;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/e4735c72/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/fallback/PagedFacetDefault.java
----------------------------------------------------------------------
diff --git a/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/fallback/PagedFacetDefault.java b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/fallback/PagedFacetDefault.java
new file mode 100644
index 0000000..eee5a1c
--- /dev/null
+++ b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/fallback/PagedFacetDefault.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.isis.core.progmodel.facets.fallback;
+
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.object.paged.PagedFacetAbstract;
+
+public class PagedFacetDefault extends PagedFacetAbstract {
+
+ public PagedFacetDefault(FacetHolder holder, int value) {
+ super(holder, value);
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/e4735c72/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/fallback/TitleFacetNone.java
----------------------------------------------------------------------
diff --git a/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/fallback/TitleFacetNone.java b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/fallback/TitleFacetNone.java
new file mode 100644
index 0000000..c54005e
--- /dev/null
+++ b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/fallback/TitleFacetNone.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.core.progmodel.facets.fallback;
+
+import org.apache.isis.applib.profiles.Localization;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.object.title.TitleFacetAbstract;
+
+public class TitleFacetNone extends TitleFacetAbstract {
+
+ public TitleFacetNone(final FacetHolder holder) {
+ super(holder);
+ }
+
+ @Override
+ public String title(final ObjectAdapter object, final Localization localization) {
+ return null;
+ }
+
+ @Override
+ public boolean isNoop() {
+ return true;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/e4735c72/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/members/describedas/annotation/DescribedAsAnnotationOnMemberFacetFactory.java
----------------------------------------------------------------------
diff --git a/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/members/describedas/annotation/DescribedAsAnnotationOnMemberFacetFactory.java b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/members/describedas/annotation/DescribedAsAnnotationOnMemberFacetFactory.java
new file mode 100644
index 0000000..3c46bbf
--- /dev/null
+++ b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/members/describedas/annotation/DescribedAsAnnotationOnMemberFacetFactory.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.core.progmodel.facets.members.describedas.annotation;
+
+import org.apache.isis.applib.annotation.DescribedAs;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facetapi.FacetUtil;
+import org.apache.isis.core.metamodel.facetapi.FeatureType;
+import org.apache.isis.core.metamodel.facets.Annotations;
+import org.apache.isis.core.metamodel.facets.FacetFactoryAbstract;
+import org.apache.isis.core.metamodel.facets.describedas.DescribedAsFacet;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+
+public class DescribedAsAnnotationOnMemberFacetFactory extends FacetFactoryAbstract {
+
+ public DescribedAsAnnotationOnMemberFacetFactory() {
+ super(FeatureType.MEMBERS);
+ }
+
+ @Override
+ public void process(final ProcessMethodContext processMethodContext) {
+
+ // look for annotation on the property
+ final DescribedAs annotation = Annotations.getAnnotation(processMethodContext.getMethod(), DescribedAs.class);
+ DescribedAsFacet facet = create(annotation, processMethodContext.getFacetHolder());
+ if (facet != null) {
+ FacetUtil.addFacet(facet);
+ return;
+ }
+
+ // otherwise, look for annotation on the type
+ final Class<?> returnType = processMethodContext.getMethod().getReturnType();
+ final DescribedAsFacet returnTypeDescribedAsFacet = getDescribedAsFacet(returnType);
+ if (returnTypeDescribedAsFacet != null) {
+ facet = new DescribedAsFacetForMemberDerivedFromType(returnTypeDescribedAsFacet, processMethodContext.getFacetHolder());
+ FacetUtil.addFacet(facet);
+ }
+ }
+
+ private DescribedAsFacet create(final DescribedAs annotation, final FacetHolder holder) {
+ return annotation == null ? null : new DescribedAsFacetAnnotationOnMember(annotation.value(), holder);
+ }
+
+ private DescribedAsFacet getDescribedAsFacet(final Class<?> type) {
+ final ObjectSpecification paramTypeSpec = getSpecificationLoader().loadSpecification(type);
+ return paramTypeSpec.getFacet(DescribedAsFacet.class);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/e4735c72/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/members/describedas/annotation/DescribedAsFacetAnnotationOnMember.java
----------------------------------------------------------------------
diff --git a/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/members/describedas/annotation/DescribedAsFacetAnnotationOnMember.java b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/members/describedas/annotation/DescribedAsFacetAnnotationOnMember.java
new file mode 100644
index 0000000..9b0ec77
--- /dev/null
+++ b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/members/describedas/annotation/DescribedAsFacetAnnotationOnMember.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.core.progmodel.facets.members.describedas.annotation;
+
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.describedas.DescribedAsFacetAbstract;
+
+public class DescribedAsFacetAnnotationOnMember extends DescribedAsFacetAbstract {
+
+ public DescribedAsFacetAnnotationOnMember(final String value, final FacetHolder holder) {
+ super(value, holder);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/e4735c72/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/members/describedas/annotation/DescribedAsFacetForMemberDerivedFromType.java
----------------------------------------------------------------------
diff --git a/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/members/describedas/annotation/DescribedAsFacetForMemberDerivedFromType.java b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/members/describedas/annotation/DescribedAsFacetForMemberDerivedFromType.java
new file mode 100644
index 0000000..a201af0
--- /dev/null
+++ b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/members/describedas/annotation/DescribedAsFacetForMemberDerivedFromType.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.core.progmodel.facets.members.describedas.annotation;
+
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.describedas.DescribedAsFacet;
+import org.apache.isis.core.metamodel.facets.describedas.DescribedAsFacetAbstract;
+
+public class DescribedAsFacetForMemberDerivedFromType extends DescribedAsFacetAbstract {
+
+ public DescribedAsFacetForMemberDerivedFromType(final DescribedAsFacet describedAsFacet, final FacetHolder holder) {
+ super(describedAsFacet.value(), holder);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/e4735c72/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/members/describedas/staticmethod/DescribedAsFacetViaDescriptionMethodFacetFactory.java
----------------------------------------------------------------------
diff --git a/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/members/describedas/staticmethod/DescribedAsFacetViaDescriptionMethodFacetFactory.java b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/members/describedas/staticmethod/DescribedAsFacetViaDescriptionMethodFacetFactory.java
new file mode 100644
index 0000000..e2a3468
--- /dev/null
+++ b/framework/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/members/describedas/staticmethod/DescribedAsFacetViaDescriptionMethodFacetFactory.java
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.core.progmodel.facets.members.describedas.staticmethod;
+
+import java.lang.reflect.Method;
+
+import org.apache.isis.core.commons.lang.NameUtils;
+import org.apache.isis.core.metamodel.adapter.util.InvokeUtils;
+import org.apache.isis.core.metamodel.exceptions.MetaModelException;
+import org.apache.isis.core.metamodel.facetapi.Facet;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facetapi.FacetUtil;
+import org.apache.isis.core.metamodel.facetapi.FeatureType;
+import org.apache.isis.core.metamodel.facets.describedas.DescribedAsFacet;
+import org.apache.isis.core.metamodel.methodutils.MethodScope;
+import org.apache.isis.core.progmodel.facets.MethodFinderUtils;
+import org.apache.isis.core.progmodel.facets.MethodPrefixBasedFacetFactoryAbstract;
+import org.apache.isis.core.progmodel.facets.MethodPrefixConstants;
+
+/**
+ * Sets up a {@link DescribedAsFacet} if a
+ * {@value MethodPrefixConstants#DESCRIPTION_PREFIX}-prefixed method is present.
+ */
+public class DescribedAsFacetViaDescriptionMethodFacetFactory extends MethodPrefixBasedFacetFactoryAbstract {
+
+ private static final String[] PREFIXES = { MethodPrefixConstants.DESCRIPTION_PREFIX };
+
+ /**
+ * Note that the {@link Facet}s registered are the generic ones from
+ * noa-architecture (where they exist)
+ */
+ public DescribedAsFacetViaDescriptionMethodFacetFactory() {
+ super(FeatureType.MEMBERS, OrphanValidation.VALIDATE, PREFIXES);
+ }
+
+ // ///////////////////////////////////////////////////////
+ // Actions
+ // ///////////////////////////////////////////////////////
+
+ @Override
+ public void process(final ProcessMethodContext processMethodContext) {
+ attachDescribedAsFacetIfDescriptionMethodIsFound(processMethodContext);
+ }
+
+ public static void attachDescribedAsFacetIfDescriptionMethodIsFound(final ProcessMethodContext processMethodContext) {
+
+ final Method method = processMethodContext.getMethod();
+ final String capitalizedName = NameUtils.javaBaseNameStripAccessorPrefixIfRequired(method.getName());
+
+ final Class<?> cls = processMethodContext.getCls();
+ final Method descriptionMethod = MethodFinderUtils.findMethod(cls, MethodScope.CLASS, MethodPrefixConstants.DESCRIPTION_PREFIX + capitalizedName, String.class, new Class[0]);
+ if (descriptionMethod == null) {
+ return;
+ }
+
+ processMethodContext.removeMethod(descriptionMethod);
+ final String description = invokeDescriptionMethod(descriptionMethod);
+
+ final FacetHolder facetedMethod = processMethodContext.getFacetHolder();
+ FacetUtil.addFacet(new DescribedAsFacetViaMethod(description, descriptionMethod, facetedMethod));
+ }
+
+ private static String invokeDescriptionMethod(final Method descriptionMethod) {
+ String description = null;
+ try {
+ description = (String) InvokeUtils.invokeStatic(descriptionMethod);
+ } catch (final ClassCastException ex) {
+ // ignore
+ }
+ if (description == null) {
+ throw new MetaModelException("method " + descriptionMethod + "must return a string");
+ }
+ return description;
+ }
+
+}