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 2014/07/11 12:56:51 UTC
[39/61] [partial] ISIS-831: digression: moving progmodel/facets into
metamodel/facets
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/callbacks/remove/RemoveCallbackViaDeleteMethodFacetFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/callbacks/remove/RemoveCallbackViaDeleteMethodFacetFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/callbacks/remove/RemoveCallbackViaDeleteMethodFacetFactory.java
new file mode 100644
index 0000000..92da2de
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/callbacks/remove/RemoveCallbackViaDeleteMethodFacetFactory.java
@@ -0,0 +1,80 @@
+/*
+ * 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.metamodel.facets.object.callbacks.remove;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+
+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.object.callbacks.RemovedCallbackFacet;
+import org.apache.isis.core.metamodel.facets.object.callbacks.RemovingCallbackFacet;
+import org.apache.isis.core.metamodel.methodutils.MethodScope;
+import org.apache.isis.core.metamodel.facets.MethodFinderUtils;
+import org.apache.isis.core.metamodel.facets.MethodPrefixBasedFacetFactoryAbstract;
+import org.apache.isis.core.metamodel.facets.MethodPrefixConstants;
+
+public class RemoveCallbackViaDeleteMethodFacetFactory extends MethodPrefixBasedFacetFactoryAbstract {
+
+ private static final String[] PREFIXES = { MethodPrefixConstants.DELETED_PREFIX, MethodPrefixConstants.DELETING_PREFIX, };
+
+ public RemoveCallbackViaDeleteMethodFacetFactory() {
+ super(FeatureType.OBJECTS_ONLY, OrphanValidation.VALIDATE, PREFIXES);
+ }
+
+ @Override
+ public void process(final ProcessClassContext processClassContext) {
+ final Class<?> cls = processClassContext.getCls();
+ final FacetHolder holder = processClassContext.getFacetHolder();
+
+ final List<Facet> facets = new ArrayList<Facet>();
+ final List<Method> methods = new ArrayList<Method>();
+
+ Method method = null;
+ method = MethodFinderUtils.findMethod(cls, MethodScope.OBJECT, MethodPrefixConstants.DELETING_PREFIX, void.class, NO_PARAMETERS_TYPES);
+ if (method != null) {
+ methods.add(method);
+ final RemovingCallbackFacet facet = holder.getFacet(RemovingCallbackFacet.class);
+ if (facet == null) {
+ facets.add(new RemovingCallbackFacetViaMethod(method, holder));
+ } else {
+ facet.addMethod(method);
+ }
+ }
+
+ method = MethodFinderUtils.findMethod(cls, MethodScope.OBJECT, MethodPrefixConstants.DELETED_PREFIX, void.class, NO_PARAMETERS_TYPES);
+ if (method != null) {
+ methods.add(method);
+ final RemovedCallbackFacet facet = holder.getFacet(RemovedCallbackFacet.class);
+ if (facet == null) {
+ facets.add(new RemovedCallbackFacetViaMethod(method, holder));
+ } else {
+ facet.addMethod(method);
+ }
+ }
+
+ processClassContext.removeMethods(methods);
+ FacetUtil.addFacets(facets);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/callbacks/remove/RemovedCallbackFacetAbstract.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/callbacks/remove/RemovedCallbackFacetAbstract.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/callbacks/remove/RemovedCallbackFacetAbstract.java
new file mode 100644
index 0000000..964070e
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/callbacks/remove/RemovedCallbackFacetAbstract.java
@@ -0,0 +1,37 @@
+/*
+ * 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.metamodel.facets.object.callbacks.remove;
+
+import org.apache.isis.core.metamodel.facetapi.Facet;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.object.callbacks.RemovedCallbackFacet;
+import org.apache.isis.core.metamodel.facets.object.callbacks.CallbackFacetAbstract;
+
+public abstract class RemovedCallbackFacetAbstract extends CallbackFacetAbstract implements RemovedCallbackFacet {
+
+ public static Class<? extends Facet> type() {
+ return RemovedCallbackFacet.class;
+ }
+
+ public RemovedCallbackFacetAbstract(final FacetHolder holder) {
+ super(type(), holder);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/callbacks/remove/RemovedCallbackFacetViaMethod.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/callbacks/remove/RemovedCallbackFacetViaMethod.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/callbacks/remove/RemovedCallbackFacetViaMethod.java
new file mode 100644
index 0000000..1f26676
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/callbacks/remove/RemovedCallbackFacetViaMethod.java
@@ -0,0 +1,76 @@
+/*
+ * 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.metamodel.facets.object.callbacks.remove;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+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 RemovedCallbackFacetViaMethod extends RemovedCallbackFacetAbstract implements ImperativeFacet {
+
+ private final List<Method> methods = new ArrayList<Method>();
+
+ public RemovedCallbackFacetViaMethod(final Method method, final FacetHolder holder) {
+ super(holder);
+ addMethod(method);
+ }
+
+ @Override
+ public void addMethod(final Method method) {
+ methods.add(method);
+ }
+
+ @Override
+ public List<Method> getMethods() {
+ return Collections.unmodifiableList(methods);
+ }
+
+ @Override
+ public Intent getIntent(final Method method) {
+ return Intent.LIFECYCLE;
+ }
+
+ @Override
+ public boolean impliesResolve() {
+ return false;
+ }
+
+ @Override
+ public boolean impliesObjectChanged() {
+ return false;
+ }
+
+ @Override
+ public void invoke(final ObjectAdapter adapter) {
+ AdapterInvokeUtils.invokeAll(methods, adapter);
+ }
+
+ @Override
+ protected String toStringValues() {
+ return "methods=" + methods;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/callbacks/remove/RemovingCallbackFacetAbstract.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/callbacks/remove/RemovingCallbackFacetAbstract.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/callbacks/remove/RemovingCallbackFacetAbstract.java
new file mode 100644
index 0000000..b150136
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/callbacks/remove/RemovingCallbackFacetAbstract.java
@@ -0,0 +1,37 @@
+/*
+ * 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.metamodel.facets.object.callbacks.remove;
+
+import org.apache.isis.core.metamodel.facetapi.Facet;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.object.callbacks.RemovingCallbackFacet;
+import org.apache.isis.core.metamodel.facets.object.callbacks.CallbackFacetAbstract;
+
+public abstract class RemovingCallbackFacetAbstract extends CallbackFacetAbstract implements RemovingCallbackFacet {
+
+ public static Class<? extends Facet> type() {
+ return RemovingCallbackFacet.class;
+ }
+
+ public RemovingCallbackFacetAbstract(final FacetHolder holder) {
+ super(type(), holder);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/callbacks/remove/RemovingCallbackFacetViaMethod.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/callbacks/remove/RemovingCallbackFacetViaMethod.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/callbacks/remove/RemovingCallbackFacetViaMethod.java
new file mode 100644
index 0000000..811be08
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/callbacks/remove/RemovingCallbackFacetViaMethod.java
@@ -0,0 +1,76 @@
+/*
+ * 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.metamodel.facets.object.callbacks.remove;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+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 RemovingCallbackFacetViaMethod extends RemovingCallbackFacetAbstract implements ImperativeFacet {
+
+ private final List<Method> methods = new ArrayList<Method>();
+
+ public RemovingCallbackFacetViaMethod(final Method method, final FacetHolder holder) {
+ super(holder);
+ addMethod(method);
+ }
+
+ @Override
+ public void addMethod(final Method method) {
+ methods.add(method);
+ }
+
+ @Override
+ public boolean impliesResolve() {
+ return false;
+ }
+
+ @Override
+ public Intent getIntent(final Method method) {
+ return Intent.LIFECYCLE;
+ }
+
+ @Override
+ public boolean impliesObjectChanged() {
+ return false;
+ }
+
+ @Override
+ public List<Method> getMethods() {
+ return Collections.unmodifiableList(methods);
+ }
+
+ @Override
+ public void invoke(final ObjectAdapter adapter) {
+ AdapterInvokeUtils.invokeAll(methods, adapter);
+ }
+
+ @Override
+ protected String toStringValues() {
+ return "methods=" + methods;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/callbacks/update/UpdateCallbackFacetFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/callbacks/update/UpdateCallbackFacetFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/callbacks/update/UpdateCallbackFacetFactory.java
new file mode 100644
index 0000000..ed84700
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/callbacks/update/UpdateCallbackFacetFactory.java
@@ -0,0 +1,68 @@
+/*
+ * 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.metamodel.facets.object.callbacks.update;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+
+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.methodutils.MethodScope;
+import org.apache.isis.core.metamodel.facets.MethodFinderUtils;
+import org.apache.isis.core.metamodel.facets.MethodPrefixBasedFacetFactoryAbstract;
+import org.apache.isis.core.metamodel.facets.MethodPrefixConstants;
+
+public class UpdateCallbackFacetFactory extends MethodPrefixBasedFacetFactoryAbstract {
+
+ private static final String[] PREFIXES = { MethodPrefixConstants.UPDATED_PREFIX, MethodPrefixConstants.UPDATING_PREFIX, };
+
+ public UpdateCallbackFacetFactory() {
+ super(FeatureType.OBJECTS_ONLY, OrphanValidation.VALIDATE, PREFIXES);
+ }
+
+ @Override
+ public void process(final ProcessClassContext processClassContext) {
+ final Class<?> cls = processClassContext.getCls();
+ final FacetHolder facetHolder = processClassContext.getFacetHolder();
+
+ final List<Facet> facets = new ArrayList<Facet>();
+ final List<Method> methods = new ArrayList<Method>();
+
+ Method method = null;
+ method = MethodFinderUtils.findMethod(cls, MethodScope.OBJECT, MethodPrefixConstants.UPDATING_PREFIX, void.class, NO_PARAMETERS_TYPES);
+ if (method != null) {
+ methods.add(method);
+ facets.add(new UpdatingCallbackFacetViaMethod(method, facetHolder));
+ }
+
+ method = MethodFinderUtils.findMethod(cls, MethodScope.OBJECT, MethodPrefixConstants.UPDATED_PREFIX, void.class, NO_PARAMETERS_TYPES);
+ if (method != null) {
+ methods.add(method);
+ facets.add(new UpdatedCallbackFacetViaMethod(method, facetHolder));
+ }
+
+ processClassContext.removeMethods(methods);
+ FacetUtil.addFacets(facets);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/callbacks/update/UpdatedCallbackFacetAbstract.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/callbacks/update/UpdatedCallbackFacetAbstract.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/callbacks/update/UpdatedCallbackFacetAbstract.java
new file mode 100644
index 0000000..541fd6d
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/callbacks/update/UpdatedCallbackFacetAbstract.java
@@ -0,0 +1,37 @@
+/*
+ * 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.metamodel.facets.object.callbacks.update;
+
+import org.apache.isis.core.metamodel.facetapi.Facet;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.object.callbacks.UpdatedCallbackFacet;
+import org.apache.isis.core.metamodel.facets.object.callbacks.CallbackFacetAbstract;
+
+public abstract class UpdatedCallbackFacetAbstract extends CallbackFacetAbstract implements UpdatedCallbackFacet {
+
+ public static Class<? extends Facet> type() {
+ return UpdatedCallbackFacet.class;
+ }
+
+ public UpdatedCallbackFacetAbstract(final FacetHolder holder) {
+ super(type(), holder);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/callbacks/update/UpdatedCallbackFacetViaMethod.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/callbacks/update/UpdatedCallbackFacetViaMethod.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/callbacks/update/UpdatedCallbackFacetViaMethod.java
new file mode 100644
index 0000000..fc97b8e
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/callbacks/update/UpdatedCallbackFacetViaMethod.java
@@ -0,0 +1,76 @@
+/*
+ * 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.metamodel.facets.object.callbacks.update;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+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 UpdatedCallbackFacetViaMethod extends UpdatedCallbackFacetAbstract implements ImperativeFacet {
+
+ private final List<Method> methods = new ArrayList<Method>();
+
+ public UpdatedCallbackFacetViaMethod(final Method method, final FacetHolder holder) {
+ super(holder);
+ addMethod(method);
+ }
+
+ @Override
+ public void addMethod(final Method method) {
+ methods.add(method);
+ }
+
+ @Override
+ public List<Method> getMethods() {
+ return Collections.unmodifiableList(methods);
+ }
+
+ @Override
+ public Intent getIntent(final Method method) {
+ return Intent.LIFECYCLE;
+ }
+
+ @Override
+ public boolean impliesResolve() {
+ return false;
+ }
+
+ @Override
+ public boolean impliesObjectChanged() {
+ return false;
+ }
+
+ @Override
+ public void invoke(final ObjectAdapter adapter) {
+ AdapterInvokeUtils.invokeAll(methods, adapter);
+ }
+
+ @Override
+ protected String toStringValues() {
+ return "methods=" + methods;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/callbacks/update/UpdatingCallbackFacetAbstract.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/callbacks/update/UpdatingCallbackFacetAbstract.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/callbacks/update/UpdatingCallbackFacetAbstract.java
new file mode 100644
index 0000000..aee1a78
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/callbacks/update/UpdatingCallbackFacetAbstract.java
@@ -0,0 +1,37 @@
+/*
+ * 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.metamodel.facets.object.callbacks.update;
+
+import org.apache.isis.core.metamodel.facetapi.Facet;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.object.callbacks.UpdatingCallbackFacet;
+import org.apache.isis.core.metamodel.facets.object.callbacks.CallbackFacetAbstract;
+
+public abstract class UpdatingCallbackFacetAbstract extends CallbackFacetAbstract implements UpdatingCallbackFacet {
+
+ public static Class<? extends Facet> type() {
+ return UpdatingCallbackFacet.class;
+ }
+
+ public UpdatingCallbackFacetAbstract(final FacetHolder holder) {
+ super(type(), holder);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/callbacks/update/UpdatingCallbackFacetViaMethod.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/callbacks/update/UpdatingCallbackFacetViaMethod.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/callbacks/update/UpdatingCallbackFacetViaMethod.java
new file mode 100644
index 0000000..8d04e2d
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/callbacks/update/UpdatingCallbackFacetViaMethod.java
@@ -0,0 +1,76 @@
+/*
+ * 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.metamodel.facets.object.callbacks.update;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+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 UpdatingCallbackFacetViaMethod extends UpdatingCallbackFacetAbstract implements ImperativeFacet {
+
+ private final List<Method> methods = new ArrayList<Method>();
+
+ public UpdatingCallbackFacetViaMethod(final Method method, final FacetHolder holder) {
+ super(holder);
+ addMethod(method);
+ }
+
+ @Override
+ public void addMethod(final Method method) {
+ methods.add(method);
+ }
+
+ @Override
+ public List<Method> getMethods() {
+ return Collections.unmodifiableList(methods);
+ }
+
+ @Override
+ public Intent getIntent(final Method method) {
+ return Intent.LIFECYCLE;
+ }
+
+ @Override
+ public boolean impliesResolve() {
+ return false;
+ }
+
+ @Override
+ public boolean impliesObjectChanged() {
+ return false;
+ }
+
+ @Override
+ public void invoke(final ObjectAdapter adapter) {
+ AdapterInvokeUtils.invokeAll(methods, adapter);
+ }
+
+ @Override
+ protected String toStringValues() {
+ return "methods=" + methods;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/choices/ChoicesFacetFromBoundedAbstract.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/choices/ChoicesFacetFromBoundedAbstract.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/choices/ChoicesFacetFromBoundedAbstract.java
new file mode 100644
index 0000000..ff20b93
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/choices/ChoicesFacetFromBoundedAbstract.java
@@ -0,0 +1,122 @@
+/*
+ * 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.metamodel.facets.object.choices;
+
+import java.util.List;
+
+import com.google.common.collect.Lists;
+
+import org.apache.isis.applib.events.UsabilityEvent;
+import org.apache.isis.applib.events.ValidityEvent;
+import org.apache.isis.applib.marker.Bounded;
+import org.apache.isis.applib.query.Query;
+import org.apache.isis.applib.query.QueryFindAllInstances;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.adapter.QuerySubmitter;
+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.facets.propparam.choices.ChoicesFacet;
+import org.apache.isis.core.metamodel.interactions.DisablingInteractionAdvisor;
+import org.apache.isis.core.metamodel.interactions.ObjectValidityContext;
+import org.apache.isis.core.metamodel.interactions.UsabilityContext;
+import org.apache.isis.core.metamodel.interactions.ValidatingInteractionAdvisor;
+import org.apache.isis.core.metamodel.interactions.ValidityContext;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+
+/**
+ * A fixed number of choices because the number of instances of this class is bounded.
+ *
+ * <p>
+ * Typically viewers will interpret this information by displaying all instances
+ * of the class in a drop-down list box or similar widget.
+ *
+ * <p>
+ * In the standard Apache Isis Programming Model, corresponds to annotating the
+ * member with {@link org.apache.isis.applib.annotation.Bounded Bounded} annotation
+ * or implementing the {@link Bounded} marker interface.
+ */
+public abstract class ChoicesFacetFromBoundedAbstract extends FacetAbstract implements ChoicesFacet, DisablingInteractionAdvisor, ValidatingInteractionAdvisor {
+
+ public static Class<? extends Facet> type() {
+ return ChoicesFacet.class;
+ }
+
+ private final QuerySubmitter querySubmitter;
+
+ public ChoicesFacetFromBoundedAbstract(final FacetHolder holder, final QuerySubmitter querySubmitter) {
+ super(type(), holder, Derivation.NOT_DERIVED);
+ this.querySubmitter = querySubmitter;
+ }
+
+ protected QuerySubmitter getQuerySubmitter() {
+ return querySubmitter;
+ }
+
+ @Override
+ public String invalidates(final ValidityContext<? extends ValidityEvent> context) {
+ if (!(context instanceof ObjectValidityContext)) {
+ return null;
+ }
+ final ObjectAdapter target = context.getTarget();
+ if(target == null) {
+ return null;
+ }
+
+ // ensure that the target is of the correct type
+ if(!(getFacetHolder() instanceof ObjectSpecification)) {
+ // should never be the case
+ return null;
+ }
+
+ final ObjectSpecification objectSpec = getObjectSpecification();
+ return objectSpec == target.getSpecification()? null: "Invalid type";
+ }
+
+ private ObjectSpecification getObjectSpecification() {
+ return (ObjectSpecification) getFacetHolder();
+ }
+
+ @Override
+ public String disables(final UsabilityContext<? extends UsabilityEvent> context) {
+ final ObjectAdapter target = context.getTarget();
+ return disabledReason(target);
+ }
+
+ /**
+ * Optional hook method for subclasses to override.
+ */
+ public String disabledReason(final ObjectAdapter inObject) {
+ return "Bounded";
+ }
+
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ @Override
+ public Object[] getChoices(ObjectAdapter adapter) {
+ final Query query = new QueryFindAllInstances(getObjectSpecification().getFullIdentifier());
+ final List<ObjectAdapter> allInstancesAdapter = getQuerySubmitter().allMatchingQuery(query);
+ final List<ObjectAdapter> adapters = Lists.newArrayList(allInstancesAdapter.iterator());
+ final List<Object> pojos = Lists.transform(adapters, ObjectAdapter.Functions.getObject());
+ return Lists.newArrayList(pojos).toArray();
+ }
+
+
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/choices/ChoicesFacetUtils.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/choices/ChoicesFacetUtils.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/choices/ChoicesFacetUtils.java
new file mode 100644
index 0000000..dcd5dd7
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/choices/ChoicesFacetUtils.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.metamodel.facets.object.choices;
+
+import org.apache.isis.core.metamodel.facets.propparam.choices.ChoicesFacet;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+
+public class ChoicesFacetUtils {
+
+ private ChoicesFacetUtils() {
+ }
+
+ /**
+ *
+ * @deprecated - use {@link ChoicesFacet.Util}
+ */
+ @Deprecated
+ public static boolean hasChoices(final ObjectSpecification specification) {
+ return ChoicesFacet.Util.hasChoices(specification);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/choices/boundedannot/ChoicesFacetFromBoundedAnnotation.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/choices/boundedannot/ChoicesFacetFromBoundedAnnotation.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/choices/boundedannot/ChoicesFacetFromBoundedAnnotation.java
new file mode 100644
index 0000000..0181d13
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/choices/boundedannot/ChoicesFacetFromBoundedAnnotation.java
@@ -0,0 +1,33 @@
+/*
+ * 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.metamodel.facets.object.choices.boundedannot;
+
+import org.apache.isis.core.metamodel.adapter.QuerySubmitter;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.object.choices.ChoicesFacetFromBoundedAbstract;
+
+public class ChoicesFacetFromBoundedAnnotation extends ChoicesFacetFromBoundedAbstract {
+
+ public ChoicesFacetFromBoundedAnnotation(final FacetHolder holder, QuerySubmitter querySubmitter) {
+ super(holder, querySubmitter);
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/choices/boundedannot/ChoicesFacetFromBoundedAnnotationFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/choices/boundedannot/ChoicesFacetFromBoundedAnnotationFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/choices/boundedannot/ChoicesFacetFromBoundedAnnotationFactory.java
new file mode 100644
index 0000000..784b6b7
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/choices/boundedannot/ChoicesFacetFromBoundedAnnotationFactory.java
@@ -0,0 +1,55 @@
+/*
+ * 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.metamodel.facets.object.choices.boundedannot;
+
+import org.apache.isis.applib.annotation.Bounded;
+import org.apache.isis.core.metamodel.adapter.QuerySubmitter;
+import org.apache.isis.core.metamodel.adapter.QuerySubmitterAware;
+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.propparam.choices.ChoicesFacet;
+
+public class ChoicesFacetFromBoundedAnnotationFactory extends FacetFactoryAbstract implements QuerySubmitterAware {
+
+ private QuerySubmitter querySubmitter;
+
+ public ChoicesFacetFromBoundedAnnotationFactory() {
+ super(FeatureType.OBJECTS_ONLY);
+ }
+
+ @Override
+ public void process(final ProcessClassContext processClassContext) {
+ final Bounded annotation = Annotations.getAnnotation(processClassContext.getCls(), Bounded.class);
+ FacetUtil.addFacet(create(annotation, processClassContext.getFacetHolder()));
+ }
+
+ private ChoicesFacet create(final Bounded annotation, final FacetHolder holder) {
+ return annotation == null ? null : new ChoicesFacetFromBoundedAnnotation(holder, querySubmitter);
+ }
+
+ @Override
+ public void setQuerySubmitter(final QuerySubmitter querySubmitter) {
+ this.querySubmitter = querySubmitter;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/choices/boundedmarkerifc/ChoicesFacetFromBoundedMarkerInterface.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/choices/boundedmarkerifc/ChoicesFacetFromBoundedMarkerInterface.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/choices/boundedmarkerifc/ChoicesFacetFromBoundedMarkerInterface.java
new file mode 100644
index 0000000..525e5db
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/choices/boundedmarkerifc/ChoicesFacetFromBoundedMarkerInterface.java
@@ -0,0 +1,33 @@
+/*
+ * 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.metamodel.facets.object.choices.boundedmarkerifc;
+
+import org.apache.isis.core.metamodel.adapter.QuerySubmitter;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.object.choices.ChoicesFacetFromBoundedAbstract;
+
+public class ChoicesFacetFromBoundedMarkerInterface extends ChoicesFacetFromBoundedAbstract {
+
+ public ChoicesFacetFromBoundedMarkerInterface(
+ final FacetHolder holder, final QuerySubmitter querySubmitter) {
+ super(holder, querySubmitter);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/choices/boundedmarkerifc/ChoicesFacetFromBoundedMarkerInterfaceFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/choices/boundedmarkerifc/ChoicesFacetFromBoundedMarkerInterfaceFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/choices/boundedmarkerifc/ChoicesFacetFromBoundedMarkerInterfaceFactory.java
new file mode 100644
index 0000000..b9be5e9
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/choices/boundedmarkerifc/ChoicesFacetFromBoundedMarkerInterfaceFactory.java
@@ -0,0 +1,60 @@
+/*
+ * 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.metamodel.facets.object.choices.boundedmarkerifc;
+
+import java.lang.reflect.Method;
+
+import org.apache.isis.applib.marker.Bounded;
+import org.apache.isis.core.metamodel.adapter.QuerySubmitter;
+import org.apache.isis.core.metamodel.adapter.QuerySubmitterAware;
+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.propparam.choices.ChoicesFacet;
+
+public class ChoicesFacetFromBoundedMarkerInterfaceFactory extends FacetFactoryAbstract implements QuerySubmitterAware {
+
+ private QuerySubmitter querySubmitter;
+
+ public ChoicesFacetFromBoundedMarkerInterfaceFactory() {
+ super(FeatureType.OBJECTS_ONLY);
+ }
+
+ @Override
+ public void process(final ProcessClassContext processClassContaxt) {
+ final boolean implementsMarker = Bounded.class.isAssignableFrom(processClassContaxt.getCls());
+ FacetUtil.addFacet(create(implementsMarker, processClassContaxt.getFacetHolder()));
+ }
+
+ private ChoicesFacet create(final boolean implementsMarker, final FacetHolder holder) {
+ return implementsMarker ? new ChoicesFacetFromBoundedMarkerInterface(holder, querySubmitter) : null;
+ }
+
+ public boolean recognizes(final Method method) {
+ return false;
+ }
+
+ @Override
+ public void setQuerySubmitter(QuerySubmitter querySubmitter) {
+ this.querySubmitter = querySubmitter;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/choices/enums/ChoicesFacetEnum.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/choices/enums/ChoicesFacetEnum.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/choices/enums/ChoicesFacetEnum.java
new file mode 100644
index 0000000..34eb2ea
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/choices/enums/ChoicesFacetEnum.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.metamodel.facets.object.choices.enums;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.propparam.choices.ChoicesFacetAbstract;
+
+public class ChoicesFacetEnum extends ChoicesFacetAbstract {
+
+ private final Object[] choices;
+
+ public ChoicesFacetEnum(final FacetHolder holder, final Object[] choices) {
+ super(holder);
+ this.choices = choices;
+ }
+
+ @Override
+ public Object[] getChoices(final ObjectAdapter adapter) {
+ return choices;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/choices/enums/EnumFacet.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/choices/enums/EnumFacet.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/choices/enums/EnumFacet.java
new file mode 100644
index 0000000..814db9e
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/choices/enums/EnumFacet.java
@@ -0,0 +1,26 @@
+/*
+ * 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.metamodel.facets.object.choices.enums;
+
+import org.apache.isis.core.metamodel.facetapi.Facet;
+
+public interface EnumFacet extends Facet {
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/choices/enums/EnumFacetUsingValueFacetUsingSemanticsProviderFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/choices/enums/EnumFacetUsingValueFacetUsingSemanticsProviderFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/choices/enums/EnumFacetUsingValueFacetUsingSemanticsProviderFactory.java
new file mode 100644
index 0000000..a45129e
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/choices/enums/EnumFacetUsingValueFacetUsingSemanticsProviderFactory.java
@@ -0,0 +1,50 @@
+/*
+ * 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.metamodel.facets.object.choices.enums;
+
+import org.apache.isis.core.commons.lang.ObjectExtensions;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facetapi.FacetUtil;
+import org.apache.isis.core.metamodel.facets.object.value.vsp.ValueFacetUsingSemanticsProviderFactory;
+
+public class EnumFacetUsingValueFacetUsingSemanticsProviderFactory<T extends Enum<T>> extends ValueFacetUsingSemanticsProviderFactory<T> {
+
+ public EnumFacetUsingValueFacetUsingSemanticsProviderFactory() {
+ super();
+ }
+
+ @Override
+ public void process(final ProcessClassContext processClassContext) {
+ final Class<?> cls = processClassContext.getCls();
+ final FacetHolder holder = processClassContext.getFacetHolder();
+
+ if (!cls.isEnum()) {
+ return;
+ }
+
+ addFacets(new EnumValueSemanticsProvider<T>(holder, asT(cls), getConfiguration(), getContext()));
+ FacetUtil.addFacet(new ChoicesFacetEnum(holder, cls.getEnumConstants()));
+ }
+
+ protected Class<T> asT(final Class<?> cls) {
+ return ObjectExtensions.asT(cls);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/choices/enums/EnumValueSemanticsProvider.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/choices/enums/EnumValueSemanticsProvider.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/choices/enums/EnumValueSemanticsProvider.java
new file mode 100644
index 0000000..561ce05
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/choices/enums/EnumValueSemanticsProvider.java
@@ -0,0 +1,98 @@
+/*
+ * 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.metamodel.facets.object.choices.enums;
+
+import org.apache.isis.applib.adapters.EncoderDecoder;
+import org.apache.isis.applib.adapters.Parser;
+import org.apache.isis.applib.profiles.Localization;
+import org.apache.isis.core.commons.config.IsisConfiguration;
+import org.apache.isis.core.metamodel.facetapi.Facet;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.object.parseable.TextEntryParseException;
+import org.apache.isis.core.metamodel.facets.object.value.vsp.ValueSemanticsProviderAndFacetAbstract;
+import org.apache.isis.core.metamodel.facets.object.value.vsp.ValueSemanticsProviderContext;
+
+public class EnumValueSemanticsProvider<T extends Enum<T>> extends ValueSemanticsProviderAndFacetAbstract<T> implements EnumFacet {
+
+ private static Class<? extends Facet> type() {
+ return EnumFacet.class;
+ }
+
+ private static <T> T defaultFor(final Class<T> adaptedClass) {
+ return adaptedClass.getEnumConstants()[0];
+ }
+
+ private static <T extends Enum<T>> int typicalLengthFor(final Class<T> adaptedClass) {
+ int max = Integer.MIN_VALUE;
+ for(T e: adaptedClass.getEnumConstants()) {
+ max = Math.max(max, e.name().length());
+ }
+ return max;
+ }
+
+ /**
+ * Required because {@link Parser} and {@link EncoderDecoder}.
+ */
+ public EnumValueSemanticsProvider() {
+ this(null, null, null, null);
+ }
+
+ public EnumValueSemanticsProvider(final FacetHolder holder, final Class<T> adaptedClass, final IsisConfiguration configuration, final ValueSemanticsProviderContext context) {
+ super(
+ type(), holder, adaptedClass,
+ typicalLengthFor(adaptedClass),
+ Immutability.IMMUTABLE,
+ EqualByContent.HONOURED,
+ defaultFor(adaptedClass),
+ configuration, context);
+ }
+
+ @Override
+ protected T doParse(final Object context, final String entry) {
+ final T[] enumConstants = getAdaptedClass().getEnumConstants();
+ for (final T enumConstant : enumConstants) {
+ if (enumConstant.toString().equals(entry)) {
+ return enumConstant;
+ }
+ }
+ throw new TextEntryParseException("Unknown enum constant '" + entry + "'");
+ }
+
+ @Override
+ protected String doEncode(final Object object) {
+ return titleString(object, null);
+ }
+
+ @Override
+ protected T doRestore(final String data) {
+ return doParse(null, data);
+ }
+
+ @Override
+ protected String titleString(final Object object, final Localization localization) {
+ return object.toString();
+ }
+
+ @Override
+ public String titleStringWithMask(final Object value, final String usingMask) {
+ return titleString(value, null);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/cssclass/annotation/CssClassFacetOnTypeAnnotation.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/cssclass/annotation/CssClassFacetOnTypeAnnotation.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/cssclass/annotation/CssClassFacetOnTypeAnnotation.java
new file mode 100644
index 0000000..ab945f7
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/cssclass/annotation/CssClassFacetOnTypeAnnotation.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.metamodel.facets.object.cssclass.annotation;
+
+import org.apache.isis.applib.annotation.CssClass;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.members.cssclass.CssClassFacetAbstract;
+
+public class CssClassFacetOnTypeAnnotation extends CssClassFacetAbstract {
+
+ public CssClassFacetOnTypeAnnotation(final CssClass cssClass, final FacetHolder holder) {
+ super(cssClass.value(), holder);
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/cssclass/annotation/CssClassFacetOnTypeAnnotationFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/cssclass/annotation/CssClassFacetOnTypeAnnotationFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/cssclass/annotation/CssClassFacetOnTypeAnnotationFactory.java
new file mode 100644
index 0000000..e97602c
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/cssclass/annotation/CssClassFacetOnTypeAnnotationFactory.java
@@ -0,0 +1,45 @@
+/*
+ * 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.metamodel.facets.object.cssclass.annotation;
+
+import org.apache.isis.applib.annotation.CssClass;
+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.members.cssclass.CssClassFacet;
+
+public class CssClassFacetOnTypeAnnotationFactory extends FacetFactoryAbstract {
+
+ public CssClassFacetOnTypeAnnotationFactory() {
+ super(FeatureType.OBJECTS_ONLY);
+ }
+
+ @Override
+ public void process(final ProcessClassContext processClassContext) {
+ final CssClass annotation = Annotations.getAnnotation(processClassContext.getCls(), CssClass.class);
+ FacetUtil.addFacet(create(annotation, processClassContext.getFacetHolder()));
+ }
+
+ private static CssClassFacet create(final CssClass annotation, final FacetHolder holder) {
+ return annotation == null ? null : new CssClassFacetOnTypeAnnotation(annotation, holder);
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/defaults/DefaultedFacet.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/defaults/DefaultedFacet.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/defaults/DefaultedFacet.java
new file mode 100644
index 0000000..322b28b
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/defaults/DefaultedFacet.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.metamodel.facets.object.defaults;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.facets.MarkerFacet;
+import org.apache.isis.core.metamodel.facets.actions.defaults.ActionDefaultsFacet;
+import org.apache.isis.core.metamodel.facets.properties.defaults.PropertyDefaultFacet;
+
+/**
+ * Indicates that this class has a default.
+ *
+ * <p>
+ * The mechanism for providing a default will vary by the applib. In the Java
+ * applib, this is done by implementing the DefaultProvider interface.
+ *
+ * <p>
+ * The rest of the framework does not used this directly, but instead we infer
+ * {@link PropertyDefaultFacet} and {@link ActionDefaultsFacet} from the
+ * method's return type / parameter types, and copy over.
+ */
+public interface DefaultedFacet extends MarkerFacet {
+
+ /**
+ * The default (as a pojo, not a {@link ObjectAdapter}).
+ *
+ * @return
+ */
+ Object getDefault();
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/defaults/DefaultedFacetAbstract.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/defaults/DefaultedFacetAbstract.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/defaults/DefaultedFacetAbstract.java
new file mode 100644
index 0000000..b56c5c3
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/defaults/DefaultedFacetAbstract.java
@@ -0,0 +1,85 @@
+/*
+ * 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.metamodel.facets.object.defaults;
+
+import org.apache.isis.applib.adapters.DefaultsProvider;
+import org.apache.isis.applib.adapters.EncoderDecoder;
+import org.apache.isis.core.commons.lang.ClassExtensions;
+import org.apache.isis.core.metamodel.facetapi.FacetAbstract;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.runtimecontext.ServicesInjector;
+
+public abstract class DefaultedFacetAbstract extends FacetAbstract implements DefaultedFacet {
+
+ private final Class<?> defaultsProviderClass;
+
+ // to delegate to
+ private final DefaultedFacetUsingDefaultsProvider defaultedFacetUsingDefaultsProvider;
+
+ private final ServicesInjector dependencyInjector;
+
+ public DefaultedFacetAbstract(final String candidateEncoderDecoderName, final Class<?> candidateEncoderDecoderClass, final FacetHolder holder, final ServicesInjector dependencyInjector) {
+ super(DefaultedFacet.class, holder, Derivation.NOT_DERIVED);
+
+ this.defaultsProviderClass = DefaultsProviderUtil.defaultsProviderOrNull(candidateEncoderDecoderClass, candidateEncoderDecoderName);
+ this.dependencyInjector = dependencyInjector;
+ if (isValid()) {
+ final DefaultsProvider<?> defaultsProvider = (DefaultsProvider<?>) ClassExtensions.newInstance(defaultsProviderClass, FacetHolder.class, holder);
+ this.defaultedFacetUsingDefaultsProvider = new DefaultedFacetUsingDefaultsProvider(defaultsProvider, holder, getDependencyInjector());
+ } else {
+ this.defaultedFacetUsingDefaultsProvider = null;
+ }
+ }
+
+ /**
+ * Discover whether either of the candidate defaults provider name or class
+ * is valid.
+ */
+ public boolean isValid() {
+ return defaultsProviderClass != null;
+ }
+
+ /**
+ * Guaranteed to implement the {@link EncoderDecoder} class, thanks to
+ * generics in the applib.
+ */
+ public Class<?> getDefaultsProviderClass() {
+ return defaultsProviderClass;
+ }
+
+ @Override
+ public Object getDefault() {
+ return defaultedFacetUsingDefaultsProvider.getDefault();
+ }
+
+ @Override
+ protected String toStringValues() {
+ return defaultsProviderClass.getName();
+ }
+
+ // //////////////////////////////////////////////////////
+ // Dependencies (from constructor)
+ // //////////////////////////////////////////////////////
+
+ private ServicesInjector getDependencyInjector() {
+ return dependencyInjector;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/defaults/DefaultedFacetUsingDefaultsProvider.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/defaults/DefaultedFacetUsingDefaultsProvider.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/defaults/DefaultedFacetUsingDefaultsProvider.java
new file mode 100644
index 0000000..c30d384
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/defaults/DefaultedFacetUsingDefaultsProvider.java
@@ -0,0 +1,58 @@
+/*
+ * 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.metamodel.facets.object.defaults;
+
+import org.apache.isis.applib.adapters.DefaultsProvider;
+import org.apache.isis.core.metamodel.facetapi.FacetAbstract;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.runtimecontext.ServicesInjector;
+
+public class DefaultedFacetUsingDefaultsProvider extends FacetAbstract implements DefaultedFacet {
+
+ private final DefaultsProvider<?> defaultsProvider;
+ private final ServicesInjector dependencyInjector;
+
+ public DefaultedFacetUsingDefaultsProvider(final DefaultsProvider<?> parser, final FacetHolder holder, final ServicesInjector dependencyInjector) {
+ super(DefaultedFacet.class, holder, Derivation.NOT_DERIVED);
+ this.defaultsProvider = parser;
+ this.dependencyInjector = dependencyInjector;
+ }
+
+ @Override
+ protected String toStringValues() {
+ getDependencyInjector().injectServicesInto(defaultsProvider);
+ return defaultsProvider.toString();
+ }
+
+ @Override
+ public Object getDefault() {
+ getDependencyInjector().injectServicesInto(defaultsProvider);
+ return defaultsProvider.getDefaultValue();
+ }
+
+ // //////////////////////////////////////////////////////
+ // Dependencies (from constructor)
+ // //////////////////////////////////////////////////////
+
+ public ServicesInjector getDependencyInjector() {
+ return dependencyInjector;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/defaults/DefaultsProviderUtil.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/defaults/DefaultsProviderUtil.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/defaults/DefaultsProviderUtil.java
new file mode 100644
index 0000000..1623996
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/defaults/DefaultsProviderUtil.java
@@ -0,0 +1,49 @@
+/*
+ * 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.metamodel.facets.object.defaults;
+
+import com.google.common.base.Strings;
+
+import org.apache.isis.applib.adapters.DefaultsProvider;
+import org.apache.isis.core.commons.config.IsisConfiguration;
+import org.apache.isis.core.commons.lang.ClassUtil;
+import org.apache.isis.core.commons.lang.StringExtensions;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+
+public final class DefaultsProviderUtil {
+
+ private DefaultsProviderUtil() {
+ }
+
+ public static final String DEFAULTS_PROVIDER_NAME_KEY_PREFIX = "isis.reflector.java.facets.defaulted.";
+ public static final String DEFAULTS_PROVIDER_NAME_KEY_SUFFIX = ".providerName";
+
+ public static String defaultsProviderNameFromConfiguration(final Class<?> type, final IsisConfiguration configuration) {
+ final String key = DEFAULTS_PROVIDER_NAME_KEY_PREFIX + type.getCanonicalName() + DEFAULTS_PROVIDER_NAME_KEY_SUFFIX;
+ final String defaultsProviderName = configuration.getString(key);
+ return !Strings.isNullOrEmpty(defaultsProviderName) ? defaultsProviderName : null;
+ }
+
+ public static Class<?> defaultsProviderOrNull(final Class<?> candidateClass, final String classCandidateName) {
+ final Class<?> type = candidateClass != null ? ClassUtil.implementingClassOrNull(candidateClass.getName(), DefaultsProvider.class, FacetHolder.class) : null;
+ return type != null ? type : ClassUtil.implementingClassOrNull(classCandidateName, DefaultsProvider.class, FacetHolder.class);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/defaults/annotcfg/DefaultedFacetAnnotation.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/defaults/annotcfg/DefaultedFacetAnnotation.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/defaults/annotcfg/DefaultedFacetAnnotation.java
new file mode 100644
index 0000000..dd65692
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/defaults/annotcfg/DefaultedFacetAnnotation.java
@@ -0,0 +1,55 @@
+/*
+ * 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.metamodel.facets.object.defaults.annotcfg;
+
+import com.google.common.base.Strings;
+
+import org.apache.isis.applib.annotation.Defaulted;
+import org.apache.isis.core.commons.config.IsisConfiguration;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.runtimecontext.ServicesInjector;
+import org.apache.isis.core.metamodel.facets.object.defaults.DefaultedFacetAbstract;
+import org.apache.isis.core.metamodel.facets.object.defaults.DefaultsProviderUtil;
+
+public class DefaultedFacetAnnotation extends DefaultedFacetAbstract {
+
+ private static String providerName(final Class<?> annotatedClass, final IsisConfiguration configuration) {
+ final Defaulted annotation = annotatedClass.getAnnotation(Defaulted.class);
+ final String providerName = annotation.defaultsProviderName();
+ if (!Strings.isNullOrEmpty(providerName)) {
+ return providerName;
+ }
+ return DefaultsProviderUtil.defaultsProviderNameFromConfiguration(annotatedClass, configuration);
+ }
+
+ private static Class<?> providerClass(final Class<?> annotatedClass) {
+ final Defaulted annotation = annotatedClass.getAnnotation(Defaulted.class);
+ return annotation.defaultsProviderClass();
+ }
+
+ public DefaultedFacetAnnotation(final Class<?> annotatedClass, final IsisConfiguration configuration, final FacetHolder holder, final ServicesInjector dependencyInjector) {
+ this(providerName(annotatedClass, configuration), providerClass(annotatedClass), holder, dependencyInjector);
+ }
+
+ private DefaultedFacetAnnotation(final String candidateProviderName, final Class<?> candidateProviderClass, final FacetHolder holder, final ServicesInjector dependencyInjector) {
+ super(candidateProviderName, candidateProviderClass, holder, dependencyInjector);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/defaults/annotcfg/DefaultedFacetAnnotationElseConfigurationFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/defaults/annotcfg/DefaultedFacetAnnotationElseConfigurationFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/defaults/annotcfg/DefaultedFacetAnnotationElseConfigurationFactory.java
new file mode 100644
index 0000000..a889860
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/defaults/annotcfg/DefaultedFacetAnnotationElseConfigurationFactory.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.metamodel.facets.object.defaults.annotcfg;
+
+import com.google.common.base.Strings;
+
+import org.apache.isis.applib.annotation.Defaulted;
+import org.apache.isis.core.commons.config.IsisConfiguration;
+import org.apache.isis.core.commons.config.IsisConfigurationAware;
+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.runtimecontext.ServicesInjector;
+import org.apache.isis.core.metamodel.runtimecontext.ServicesInjectorAware;
+import org.apache.isis.core.metamodel.facets.object.defaults.DefaultedFacetAbstract;
+import org.apache.isis.core.metamodel.facets.object.defaults.DefaultsProviderUtil;
+
+public class DefaultedFacetAnnotationElseConfigurationFactory extends FacetFactoryAbstract implements IsisConfigurationAware, ServicesInjectorAware {
+
+ private IsisConfiguration configuration;
+ private ServicesInjector servicesInjector;
+
+ public DefaultedFacetAnnotationElseConfigurationFactory() {
+ super(FeatureType.OBJECTS_ONLY);
+ }
+
+ @Override
+ public void process(final ProcessClassContext processClassContext) {
+ FacetUtil.addFacet(create(processClassContext.getCls(), processClassContext.getFacetHolder()));
+ }
+
+ private DefaultedFacetAbstract create(final Class<?> cls, final FacetHolder holder) {
+ final Defaulted annotation = Annotations.getAnnotation(cls, Defaulted.class);
+
+ // create from annotation, if present
+ if (annotation != null) {
+ final DefaultedFacetAbstract facet = new DefaultedFacetAnnotation(cls, getIsisConfiguration(), holder, getServicesInjector());
+ if (facet.isValid()) {
+ return facet;
+ }
+ }
+
+ // otherwise, try to create from configuration, if present
+ final String providerName = DefaultsProviderUtil.defaultsProviderNameFromConfiguration(cls, getIsisConfiguration());
+ if (!Strings.isNullOrEmpty(providerName)) {
+ final DefaultedFacetFromConfiguration facet = new DefaultedFacetFromConfiguration(providerName, holder, getServicesInjector());
+ if (facet.isValid()) {
+ return facet;
+ }
+ }
+
+ return null;
+ }
+
+ // ////////////////////////////////////////////////////////////////////
+ // Injected
+ // ////////////////////////////////////////////////////////////////////
+
+ public IsisConfiguration getIsisConfiguration() {
+ return configuration;
+ }
+
+ @Override
+ public void setConfiguration(final IsisConfiguration configuration) {
+ this.configuration = configuration;
+ }
+
+ private ServicesInjector getServicesInjector() {
+ return servicesInjector;
+ }
+
+ @Override
+ public void setServicesInjector(final ServicesInjector dependencyInjector) {
+ this.servicesInjector = dependencyInjector;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/defaults/annotcfg/DefaultedFacetFromConfiguration.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/defaults/annotcfg/DefaultedFacetFromConfiguration.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/defaults/annotcfg/DefaultedFacetFromConfiguration.java
new file mode 100644
index 0000000..ec2096b
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/defaults/annotcfg/DefaultedFacetFromConfiguration.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.metamodel.facets.object.defaults.annotcfg;
+
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.runtimecontext.ServicesInjector;
+import org.apache.isis.core.metamodel.facets.object.defaults.DefaultedFacetAbstract;
+
+public class DefaultedFacetFromConfiguration extends DefaultedFacetAbstract {
+
+ public DefaultedFacetFromConfiguration(final String candidateProviderName, final FacetHolder holder, final ServicesInjector dependencyInjector) {
+ super(candidateProviderName, null, holder, dependencyInjector);
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/describedas/annotation/DescribedAsFacetOnTypeAnnotation.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/describedas/annotation/DescribedAsFacetOnTypeAnnotation.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/describedas/annotation/DescribedAsFacetOnTypeAnnotation.java
new file mode 100644
index 0000000..0d094e9
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/describedas/annotation/DescribedAsFacetOnTypeAnnotation.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.metamodel.facets.object.describedas.annotation;
+
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.all.describedas.DescribedAsFacetAbstract;
+
+public class DescribedAsFacetOnTypeAnnotation extends DescribedAsFacetAbstract {
+
+ public DescribedAsFacetOnTypeAnnotation(final String value, final FacetHolder holder) {
+ super(value, holder);
+ }
+
+}