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:49 UTC
[37/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/hidden/HiddenObjectFacet.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/hidden/HiddenObjectFacet.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/hidden/HiddenObjectFacet.java
new file mode 100644
index 0000000..155b390
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/hidden/HiddenObjectFacet.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.hidden;
+
+import org.apache.isis.core.metamodel.facetapi.Facet;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.interactions.HidingInteractionAdvisor;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.metamodel.spec.feature.ObjectMember;
+
+/**
+ * Mechanism for determining whether this object is should be hidden.
+ *
+ * <p>
+ * Even though all the properties of an object may themselves be visible, there
+ * could be reasons to hide the object.
+ * </p>
+ *
+ * <p>
+ * In the standard Apache Isis Programming Model, typically corresponds to the
+ * <tt>hidden</tt> method.
+ * </p>
+ *
+ * @see org.apache.isis.core.metamodel.facets.all.hide.HiddenFacet
+ */
+public interface HiddenObjectFacet extends Facet, HidingInteractionAdvisor {
+
+ /**
+ * Clone this facet onto another {@link FacetHolder}.
+ *
+ * <p>
+ * Introduced to allow this facet to be installed onto the
+ * {@link ObjectSpecification}, and then copied down onto each of the spec's
+ * {@link ObjectMember}s.
+ */
+ public void copyOnto(FacetHolder holder);
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/hidden/HiddenObjectFacetAbstract.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/hidden/HiddenObjectFacetAbstract.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/hidden/HiddenObjectFacetAbstract.java
new file mode 100644
index 0000000..cd6d3e4
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/hidden/HiddenObjectFacetAbstract.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.hidden;
+
+import org.apache.isis.applib.events.VisibilityEvent;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+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.VisibilityContext;
+
+public abstract class HiddenObjectFacetAbstract extends FacetAbstract implements HiddenObjectFacet {
+
+ public static Class<? extends Facet> type() {
+ return HiddenObjectFacet.class;
+ }
+
+ public HiddenObjectFacetAbstract(final FacetHolder holder) {
+ super(type(), holder, Derivation.NOT_DERIVED);
+ }
+
+ @Override
+ public String hides(final VisibilityContext<? extends VisibilityEvent> ic) {
+ if (!(ic instanceof VisibilityContext)) {
+ return null;
+ }
+ final ObjectAdapter toValidate = ic.getTarget();
+ return toValidate != null ? hiddenReason(toValidate) : null;
+ }
+
+ protected abstract String hiddenReason(ObjectAdapter toHide);
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/hidden/annotation/HiddenFacetOnTypeAnnotation.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/hidden/annotation/HiddenFacetOnTypeAnnotation.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/hidden/annotation/HiddenFacetOnTypeAnnotation.java
new file mode 100644
index 0000000..6058189
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/hidden/annotation/HiddenFacetOnTypeAnnotation.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.hidden.annotation;
+
+import org.apache.isis.applib.annotation.When;
+import org.apache.isis.applib.annotation.Where;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.members.hidden.HiddenFacetImpl;
+
+public class HiddenFacetOnTypeAnnotation extends HiddenFacetImpl {
+
+ public HiddenFacetOnTypeAnnotation(final When when, final FacetHolder holder) {
+ super(when, Where.ANYWHERE, holder);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/hidden/annotation/HiddenFacetOnTypeAnnotationFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/hidden/annotation/HiddenFacetOnTypeAnnotationFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/hidden/annotation/HiddenFacetOnTypeAnnotationFactory.java
new file mode 100644
index 0000000..c2a0011
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/hidden/annotation/HiddenFacetOnTypeAnnotationFactory.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.metamodel.facets.object.hidden.annotation;
+
+import org.apache.isis.applib.annotation.Hidden;
+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.all.hide.HiddenFacet;
+
+public class HiddenFacetOnTypeAnnotationFactory extends FacetFactoryAbstract {
+
+ public HiddenFacetOnTypeAnnotationFactory() {
+ super(FeatureType.OBJECTS_ONLY);
+ }
+
+ @Override
+ public void process(final ProcessClassContext processClassContext) {
+ final Hidden annotation = Annotations.getAnnotation(processClassContext.getCls(), Hidden.class);
+ FacetUtil.addFacet(create(annotation, processClassContext.getFacetHolder()));
+ }
+
+ private static HiddenFacet create(final Hidden annotation, final FacetHolder holder) {
+ return annotation == null ? null : new HiddenFacetOnTypeAnnotation(annotation.when(), holder);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/hidden/method/HiddenObjectFacetViaMethod.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/hidden/method/HiddenObjectFacetViaMethod.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/hidden/method/HiddenObjectFacetViaMethod.java
new file mode 100644
index 0000000..74f0a89
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/hidden/method/HiddenObjectFacetViaMethod.java
@@ -0,0 +1,61 @@
+/*
+ * 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.hidden.method;
+
+import java.lang.reflect.Method;
+
+import org.apache.isis.applib.events.VisibilityEvent;
+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.facetapi.FacetUtil;
+import org.apache.isis.core.metamodel.interactions.VisibilityContext;
+import org.apache.isis.core.metamodel.facets.object.hidden.HiddenObjectFacetAbstract;
+
+public class HiddenObjectFacetViaMethod extends HiddenObjectFacetAbstract {
+ private final Method method;
+
+ public HiddenObjectFacetViaMethod(final Method method, final FacetHolder holder) {
+ super(holder);
+ this.method = method;
+ }
+
+ @Override
+ public String hides(final VisibilityContext<? extends VisibilityEvent> ic) {
+ final ObjectAdapter toValidate = ic.getTarget();
+ return toValidate != null ? hiddenReason(toValidate) : null;
+ }
+
+ @Override
+ public String hiddenReason(final ObjectAdapter target) {
+ if (target == null) {
+ return null;
+ }
+ final Boolean isHidden = (Boolean) AdapterInvokeUtils.invoke(method, target);
+ return isHidden.booleanValue() ? "Hidden" : null;
+ }
+
+ @Override
+ public void copyOnto(final FacetHolder holder) {
+ final HiddenObjectFacetViaMethod clonedFacet = new HiddenObjectFacetViaMethod(this.method, holder);
+ FacetUtil.addFacet(clonedFacet);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/hidden/method/HiddenObjectFacetViaMethodFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/hidden/method/HiddenObjectFacetViaMethodFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/hidden/method/HiddenObjectFacetViaMethodFactory.java
new file mode 100644
index 0000000..9396981
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/hidden/method/HiddenObjectFacetViaMethodFactory.java
@@ -0,0 +1,90 @@
+/*
+ * 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.hidden.method;
+
+import java.lang.reflect.Method;
+
+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.FacetedMethod;
+import org.apache.isis.core.metamodel.facets.object.hidden.HiddenObjectFacet;
+import org.apache.isis.core.metamodel.methodutils.MethodScope;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.metamodel.spec.feature.ObjectMember;
+import org.apache.isis.core.metamodel.facets.MethodFinderUtils;
+import org.apache.isis.core.metamodel.facets.MethodPrefixBasedFacetFactoryAbstract;
+
+/**
+ * Installs the {@link HiddenObjectFacetViaMethod} on the
+ * {@link ObjectSpecification}, and copies this facet onto each
+ * {@link ObjectMember}.
+ *
+ * <p>
+ * This two-pass design is required because, at the time that the
+ * {@link #process(org.apache.isis.core.metamodel.facets.FacetFactory.ProcessClassContext)
+ * class is being processed}, the {@link ObjectMember member}s for the
+ * {@link ObjectSpecification spec} are not known.
+ */
+public class HiddenObjectFacetViaMethodFactory extends MethodPrefixBasedFacetFactoryAbstract {
+
+ private static final String HIDDEN_PREFIX = "hidden";
+
+ private static final String[] PREFIXES = { HIDDEN_PREFIX, };
+
+ public HiddenObjectFacetViaMethodFactory() {
+ super(FeatureType.EVERYTHING_BUT_PARAMETERS, OrphanValidation.VALIDATE, PREFIXES);
+ }
+
+ @Override
+ public void process(final ProcessClassContext processClassContext) {
+ for (final Class<?> returnType : new Class<?>[] { Boolean.class, boolean.class }) {
+ if (addFacetIfMethodFound(processClassContext, returnType)) {
+ return;
+ }
+ }
+ return;
+ }
+
+ @Override
+ public void process(final ProcessMethodContext processMethodContext) {
+ final FacetedMethod member = processMethodContext.getFacetHolder();
+ final Class<?> owningClass = processMethodContext.getCls();
+ final ObjectSpecification owningSpec = getSpecificationLoader().loadSpecification(owningClass);
+ final HiddenObjectFacet facet = owningSpec.getFacet(HiddenObjectFacet.class);
+ if (facet != null) {
+ facet.copyOnto(member);
+ }
+ }
+
+ private boolean addFacetIfMethodFound(final ProcessClassContext processClassContext, final Class<?> returnType) {
+ final Class<?> cls = processClassContext.getCls();
+ final FacetHolder facetHolder = processClassContext.getFacetHolder();
+
+ final Method method = MethodFinderUtils.findMethod(cls, MethodScope.OBJECT, HIDDEN_PREFIX, returnType, NO_PARAMETERS_TYPES);
+ if (method == null) {
+ return false;
+ }
+ FacetUtil.addFacet(new HiddenObjectFacetViaMethod(method, facetHolder));
+ processClassContext.removeMethod(method);
+ return true;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/icon/method/IconFacetMethod.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/icon/method/IconFacetMethod.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/icon/method/IconFacetMethod.java
new file mode 100644
index 0000000..4753e7b
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/icon/method/IconFacetMethod.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.icon.method;
+
+import java.lang.reflect.Method;
+
+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.object.icon.IconFacetAbstract;
+
+public class IconFacetMethod extends IconFacetAbstract {
+
+ private final Method method;
+
+ public IconFacetMethod(final Method method, final FacetHolder holder) {
+ super(holder);
+ this.method = method;
+ }
+
+ @Override
+ public String iconName(final ObjectAdapter owningAdapter) {
+ try {
+ return (String) AdapterInvokeUtils.invoke(method, owningAdapter);
+ } catch (final RuntimeException ex) {
+ return null;
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/icon/method/IconFacetMethodFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/icon/method/IconFacetMethodFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/icon/method/IconFacetMethodFactory.java
new file mode 100644
index 0000000..04dcf1a
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/icon/method/IconFacetMethodFactory.java
@@ -0,0 +1,53 @@
+/*
+ * 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.icon.method;
+
+import java.lang.reflect.Method;
+
+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;
+
+public class IconFacetMethodFactory extends MethodPrefixBasedFacetFactoryAbstract {
+
+ private static final String ICON_NAME_PREFIX = "iconName";
+
+ private static final String[] PREFIXES = { ICON_NAME_PREFIX, };
+
+ public IconFacetMethodFactory() {
+ 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 Method method = MethodFinderUtils.findMethod(cls, MethodScope.OBJECT, ICON_NAME_PREFIX, String.class, NO_PARAMETERS_TYPES);
+ if (method == null) {
+ return;
+ }
+ processClassContext.removeMethod(method);
+ FacetUtil.addFacet(new IconFacetMethod(method, facetHolder));
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/ignore/annotation/RemoveProgrammaticOrIgnoreAnnotationMethodsFacetFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/ignore/annotation/RemoveProgrammaticOrIgnoreAnnotationMethodsFacetFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/ignore/annotation/RemoveProgrammaticOrIgnoreAnnotationMethodsFacetFactory.java
new file mode 100644
index 0000000..5dc7d32
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/ignore/annotation/RemoveProgrammaticOrIgnoreAnnotationMethodsFacetFactory.java
@@ -0,0 +1,63 @@
+/*
+ * 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.ignore.annotation;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+
+import org.apache.isis.applib.annotation.Ignore;
+import org.apache.isis.applib.annotation.Programmatic;
+import org.apache.isis.core.metamodel.facetapi.FeatureType;
+import org.apache.isis.core.metamodel.facetapi.MethodRemover;
+import org.apache.isis.core.metamodel.facets.Annotations;
+import org.apache.isis.core.metamodel.facets.FacetFactoryAbstract;
+
+public class RemoveProgrammaticOrIgnoreAnnotationMethodsFacetFactory extends FacetFactoryAbstract {
+
+ public RemoveProgrammaticOrIgnoreAnnotationMethodsFacetFactory() {
+ super(FeatureType.OBJECTS_ONLY);
+ }
+
+ @Override
+ public void process(final ProcessClassContext processClassContext) {
+ removeIgnoredMethods(processClassContext.getCls(), processClassContext);
+ }
+
+ @SuppressWarnings("deprecation")
+ private void removeIgnoredMethods(final Class<?> cls, final MethodRemover methodRemover) {
+ if (cls == null) {
+ return;
+ }
+
+ final Method[] methods = cls.getMethods();
+ for (final Method method : methods) {
+ removeAnnotatedMethods(methodRemover, method, Ignore.class);
+ removeAnnotatedMethods(methodRemover, method, Programmatic.class);
+ }
+ }
+
+ private static <T extends Annotation> void removeAnnotatedMethods(final MethodRemover methodRemover, final Method method, Class<T> annotationClass) {
+ if (!Annotations.isAnnotationPresent(method, annotationClass)) {
+ return;
+ }
+ methodRemover.removeMethod(method);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/ignore/isis/RemoveSetDomainObjectContainerMethodFacetFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/ignore/isis/RemoveSetDomainObjectContainerMethodFacetFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/ignore/isis/RemoveSetDomainObjectContainerMethodFacetFactory.java
new file mode 100644
index 0000000..1c25439
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/ignore/isis/RemoveSetDomainObjectContainerMethodFacetFactory.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.metamodel.facets.object.ignore.isis;
+
+import org.apache.isis.applib.DomainObjectContainer;
+import org.apache.isis.core.metamodel.facetapi.FeatureType;
+import org.apache.isis.core.metamodel.facets.FacetFactoryAbstract;
+import org.apache.isis.core.metamodel.methodutils.MethodScope;
+
+/**
+ * Removes any calls to <tt>setContainer(DomainObjectContainer)</tt>.
+ */
+public class RemoveSetDomainObjectContainerMethodFacetFactory extends FacetFactoryAbstract {
+
+ public RemoveSetDomainObjectContainerMethodFacetFactory() {
+ super(FeatureType.OBJECTS_ONLY);
+ }
+
+ @Override
+ public void process(final ProcessClassContext processClassContext) {
+ processClassContext.removeMethod(MethodScope.OBJECT, "setContainer", void.class, new Class[] { DomainObjectContainer.class });
+ processClassContext.removeMethod(MethodScope.OBJECT, "set_Container", void.class, new Class[] { DomainObjectContainer.class });
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/ignore/isis/RemoveStaticGettersAndSettersFacetFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/ignore/isis/RemoveStaticGettersAndSettersFacetFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/ignore/isis/RemoveStaticGettersAndSettersFacetFactory.java
new file mode 100644
index 0000000..e3c83ac
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/ignore/isis/RemoveStaticGettersAndSettersFacetFactory.java
@@ -0,0 +1,41 @@
+/*
+ * 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.ignore.isis;
+
+import org.apache.isis.core.metamodel.facetapi.FeatureType;
+import org.apache.isis.core.metamodel.facets.FacetFactoryAbstract;
+import org.apache.isis.core.metamodel.methodutils.MethodScope;
+
+/**
+ * Removes any static getter or setter methods.
+ */
+public class RemoveStaticGettersAndSettersFacetFactory extends FacetFactoryAbstract {
+
+ public RemoveStaticGettersAndSettersFacetFactory() {
+ super(FeatureType.OBJECTS_ONLY);
+ }
+
+ @Override
+ public void process(final ProcessClassContext processClassContext) {
+ processClassContext.removeMethods(MethodScope.CLASS, "get", null, false, 0);
+ processClassContext.removeMethods(MethodScope.CLASS, "set", null, false, 0);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/ignore/javalang/AbstractRemoveMethodsFacetFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/ignore/javalang/AbstractRemoveMethodsFacetFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/ignore/javalang/AbstractRemoveMethodsFacetFactory.java
new file mode 100644
index 0000000..87c139d
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/ignore/javalang/AbstractRemoveMethodsFacetFactory.java
@@ -0,0 +1,81 @@
+/*
+ * 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.ignore.javalang;
+
+import java.lang.reflect.Method;
+import java.util.List;
+
+import com.google.common.collect.Lists;
+
+import org.apache.isis.core.commons.factory.InstanceUtil;
+import org.apache.isis.core.metamodel.facetapi.FeatureType;
+import org.apache.isis.core.metamodel.facets.FacetFactoryAbstract;
+import org.apache.isis.core.metamodel.methodutils.MethodScope;
+
+/**
+ * Removes all methods inherited specified class.
+ */
+public abstract class AbstractRemoveMethodsFacetFactory extends FacetFactoryAbstract {
+
+ private static class MethodAndParameterTypes {
+ private final String methodName;
+ private final Class<?>[] methodParameters;
+
+ public MethodAndParameterTypes(final String methodName, final Class<?>[] methodParameters) {
+ this.methodName = methodName;
+ this.methodParameters = methodParameters;
+ }
+ }
+
+ private final List<MethodAndParameterTypes> methodsToIgnore = Lists.newArrayList();
+
+ public AbstractRemoveMethodsFacetFactory(final Class<?> typeToIgnore) {
+ super(FeatureType.OBJECTS_ONLY);
+ final Method[] methods = typeToIgnore.getMethods();
+ for (final Method method : methods) {
+ methodsToIgnore.add(new MethodAndParameterTypes(method.getName(), method.getParameterTypes()));
+ }
+ }
+
+ public AbstractRemoveMethodsFacetFactory(final String typeToIgnoreIfOnClasspath) {
+ super(FeatureType.OBJECTS_ONLY);
+ try {
+ Class<?> typeToIgnore = InstanceUtil.loadClass(typeToIgnoreIfOnClasspath);
+ addMethodsToBeIgnored(typeToIgnore);
+ } catch(Exception ex) {
+ // ignore
+ }
+ }
+
+ private void addMethodsToBeIgnored(Class<?> typeToIgnore) {
+ final Method[] methods = typeToIgnore.getMethods();
+ for (final Method method : methods) {
+ methodsToIgnore.add(new MethodAndParameterTypes(method.getName(), method.getParameterTypes()));
+ }
+ }
+
+ @Override
+ public void process(final ProcessClassContext processClassContext) {
+ for (final MethodAndParameterTypes mapt : methodsToIgnore) {
+ processClassContext.removeMethod(MethodScope.OBJECT, mapt.methodName, null, mapt.methodParameters);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/ignore/javalang/IteratorFilteringFacetFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/ignore/javalang/IteratorFilteringFacetFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/ignore/javalang/IteratorFilteringFacetFactory.java
new file mode 100644
index 0000000..a55a6b5
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/ignore/javalang/IteratorFilteringFacetFactory.java
@@ -0,0 +1,56 @@
+/*
+ * 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.ignore.javalang;
+
+import java.lang.reflect.Method;
+
+import org.apache.isis.core.metamodel.facetapi.Facet;
+import org.apache.isis.core.metamodel.facetapi.FeatureType;
+import org.apache.isis.core.metamodel.facets.FacetFactoryAbstract;
+import org.apache.isis.core.metamodel.facets.MethodFilteringFacetFactory;
+import org.apache.isis.core.metamodel.methodutils.MethodScope;
+
+/**
+ * Designed to simply filter out {@link Iterable#iterator()} method if it
+ * exists.
+ *
+ * <p>
+ * Does not add any {@link Facet}s.
+ */
+public class IteratorFilteringFacetFactory extends FacetFactoryAbstract implements MethodFilteringFacetFactory {
+
+ public IteratorFilteringFacetFactory() {
+ super(FeatureType.OBJECTS_ONLY);
+ }
+
+ @Override
+ public void process(final ProcessClassContext processClassContaxt) {
+ processClassContaxt.removeMethod(MethodScope.OBJECT, "iterator", java.util.Iterator.class, new Class[] {});
+ }
+
+ @Override
+ public boolean recognizes(final Method method) {
+ if (method.toString().equals("public abstract java.util.Iterator java.lang.Iterable.iterator()")) {
+ return true;
+ }
+ return false;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/ignore/javalang/RemoveGetClassMethodFacetFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/ignore/javalang/RemoveGetClassMethodFacetFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/ignore/javalang/RemoveGetClassMethodFacetFactory.java
new file mode 100644
index 0000000..781f640
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/ignore/javalang/RemoveGetClassMethodFacetFactory.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.metamodel.facets.object.ignore.javalang;
+
+import org.apache.isis.core.metamodel.facetapi.FeatureType;
+import org.apache.isis.core.metamodel.facets.FacetFactoryAbstract;
+import org.apache.isis.core.metamodel.methodutils.MethodScope;
+
+/**
+ * Removes any static getter or setter methods.
+ *
+ * <p>
+ * TODO: this is probably redundant given we also have
+ * {@link RemoveJavaLangObjectMethodsFacetFactory}.
+ */
+public class RemoveGetClassMethodFacetFactory extends FacetFactoryAbstract {
+
+ public RemoveGetClassMethodFacetFactory() {
+ super(FeatureType.OBJECTS_ONLY);
+ }
+
+ @Override
+ public void process(final ProcessClassContext processClassContext) {
+ processClassContext.removeMethod(MethodScope.OBJECT, "getClass", Class.class, null);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/ignore/javalang/RemoveInitMethodFacetFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/ignore/javalang/RemoveInitMethodFacetFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/ignore/javalang/RemoveInitMethodFacetFactory.java
new file mode 100644
index 0000000..2223dc0
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/ignore/javalang/RemoveInitMethodFacetFactory.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.ignore.javalang;
+
+import org.apache.isis.core.metamodel.facetapi.FeatureType;
+import org.apache.isis.core.metamodel.facets.FacetFactoryAbstract;
+import org.apache.isis.core.metamodel.methodutils.MethodScope;
+
+/**
+ * Removes any calls to <tt>init</tt>.
+ */
+public class RemoveInitMethodFacetFactory extends FacetFactoryAbstract {
+
+ public RemoveInitMethodFacetFactory() {
+ super(FeatureType.OBJECTS_ONLY);
+ }
+
+ @Override
+ public void process(final ProcessClassContext processClassContext) {
+ processClassContext.removeMethod(MethodScope.OBJECT, "init", void.class, new Class[0]);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/ignore/javalang/RemoveInjectMethodsFacetFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/ignore/javalang/RemoveInjectMethodsFacetFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/ignore/javalang/RemoveInjectMethodsFacetFactory.java
new file mode 100644
index 0000000..51a1459
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/ignore/javalang/RemoveInjectMethodsFacetFactory.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.ignore.javalang;
+
+import java.lang.reflect.Method;
+
+import org.apache.isis.core.metamodel.facetapi.FeatureType;
+import org.apache.isis.core.metamodel.facets.FacetFactoryAbstract;
+import org.apache.isis.core.metamodel.services.ServicesInjectorDefault;
+
+public class RemoveInjectMethodsFacetFactory extends FacetFactoryAbstract {
+
+ public RemoveInjectMethodsFacetFactory() {
+ super(FeatureType.OBJECTS_ONLY);
+ }
+
+ @Override
+ public void process(final ProcessClassContext processClassContext) {
+ for (Class<? extends Object> serviceClass : getSpecificationLoader().getServiceClasses()) {
+ Method[] methods = processClassContext.getCls().getMethods();
+ for (Method method : methods) {
+ if(ServicesInjectorDefault.isInjectorMethodFor(method, serviceClass)) {
+ processClassContext.removeMethod(method);
+ }
+ }
+ }
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/ignore/javalang/RemoveJavaLangComparableMethodsFacetFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/ignore/javalang/RemoveJavaLangComparableMethodsFacetFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/ignore/javalang/RemoveJavaLangComparableMethodsFacetFactory.java
new file mode 100644
index 0000000..a162c20
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/ignore/javalang/RemoveJavaLangComparableMethodsFacetFactory.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.ignore.javalang;
+
+import java.lang.reflect.Method;
+
+import org.apache.isis.core.metamodel.facetapi.FeatureType;
+import org.apache.isis.core.metamodel.facets.FacetFactoryAbstract;
+
+/**
+ * Removes all methods called <tt>compareTo</tt>.
+ */
+public class RemoveJavaLangComparableMethodsFacetFactory extends FacetFactoryAbstract {
+
+ public RemoveJavaLangComparableMethodsFacetFactory() {
+ super(FeatureType.OBJECTS_ONLY);
+ }
+
+ @Override
+ public void process(final ProcessClassContext processClassContext) {
+ super.process(processClassContext);
+ Class<?> cls = processClassContext.getCls();
+ Method[] methods = cls.getMethods(); // not getDeclaredMethods !!!
+ for (Method method : methods) {
+ if(method.getName().equals("compareTo")) {
+ processClassContext.removeMethod(method);
+ }
+
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/ignore/javalang/RemoveJavaLangObjectMethodsFacetFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/ignore/javalang/RemoveJavaLangObjectMethodsFacetFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/ignore/javalang/RemoveJavaLangObjectMethodsFacetFactory.java
new file mode 100644
index 0000000..93a395e
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/ignore/javalang/RemoveJavaLangObjectMethodsFacetFactory.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.ignore.javalang;
+
+/**
+ * Removes all methods inherited from {@link Object}.
+ */
+public class RemoveJavaLangObjectMethodsFacetFactory extends AbstractRemoveMethodsFacetFactory {
+
+ public RemoveJavaLangObjectMethodsFacetFactory() {
+ super(Object.class);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/ignore/javalang/RemoveSuperclassMethodsFacetFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/ignore/javalang/RemoveSuperclassMethodsFacetFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/ignore/javalang/RemoveSuperclassMethodsFacetFactory.java
new file mode 100644
index 0000000..163ce79
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/ignore/javalang/RemoveSuperclassMethodsFacetFactory.java
@@ -0,0 +1,65 @@
+/*
+ * 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.ignore.javalang;
+
+import java.lang.reflect.Method;
+
+import org.apache.isis.core.commons.lang.ClassExtensions;
+import org.apache.isis.core.metamodel.facetapi.Facet;
+import org.apache.isis.core.metamodel.facetapi.FeatureType;
+import org.apache.isis.core.metamodel.facetapi.MethodRemover;
+import org.apache.isis.core.metamodel.facets.FacetFactoryAbstract;
+
+/**
+ * Removes all superclass methods of the class, but doesn't add any
+ * {@link Facet}s.
+ */
+public class RemoveSuperclassMethodsFacetFactory extends FacetFactoryAbstract {
+
+ @SuppressWarnings("unused")
+ private static final String JAVA_CLASS_PREFIX = "java.";
+
+ public RemoveSuperclassMethodsFacetFactory() {
+ super(FeatureType.OBJECTS_ONLY);
+ }
+
+ @Override
+ public void process(final ProcessClassContext processClassContext) {
+ removeSuperclassMethods(processClassContext.getCls(), processClassContext);
+ }
+
+ private void removeSuperclassMethods(final Class<?> type, final MethodRemover methodRemover) {
+ if (type == null) {
+ return;
+ }
+
+ if (!ClassExtensions.isJavaClass(type)) {
+ removeSuperclassMethods(type.getSuperclass(), methodRemover);
+ return;
+ }
+
+ final Method[] methods = type.getMethods();
+ for (final Method method : methods) {
+ methodRemover.removeMethod(method);
+ }
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/ignore/javalang/RemoveSyntheticOrAbstractMethodsFacetFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/ignore/javalang/RemoveSyntheticOrAbstractMethodsFacetFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/ignore/javalang/RemoveSyntheticOrAbstractMethodsFacetFactory.java
new file mode 100644
index 0000000..62ab3db
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/ignore/javalang/RemoveSyntheticOrAbstractMethodsFacetFactory.java
@@ -0,0 +1,52 @@
+/*
+ * 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.ignore.javalang;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+
+import org.apache.isis.core.metamodel.facetapi.Facet;
+import org.apache.isis.core.metamodel.facetapi.FeatureType;
+import org.apache.isis.core.metamodel.facets.FacetFactoryAbstract;
+
+/**
+ * Designed to simply filter out any synthetic methods.
+ *
+ * <p>
+ * Does not add any {@link Facet}s.
+ */
+public class RemoveSyntheticOrAbstractMethodsFacetFactory extends FacetFactoryAbstract {
+
+ public RemoveSyntheticOrAbstractMethodsFacetFactory() {
+ super(FeatureType.OBJECTS_ONLY);
+ }
+
+ @Override
+ public void process(final ProcessClassContext processClassContext) {
+ super.process(processClassContext);
+ Class<?> cls = processClassContext.getCls();
+ Method[] methods = cls.getMethods();
+ for (Method method : methods) {
+ if (method.isSynthetic() || Modifier.isAbstract(method.getModifiers())) {
+ processClassContext.removeMethod(method);
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/ignore/jdo/RemoveJdoEnhancementTypesFacetFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/ignore/jdo/RemoveJdoEnhancementTypesFacetFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/ignore/jdo/RemoveJdoEnhancementTypesFacetFactory.java
new file mode 100644
index 0000000..7f40f19
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/ignore/jdo/RemoveJdoEnhancementTypesFacetFactory.java
@@ -0,0 +1,34 @@
+/*
+ * 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.ignore.jdo;
+
+
+import org.apache.isis.core.metamodel.facets.object.ignore.javalang.AbstractRemoveMethodsFacetFactory;
+
+/**
+ * Removes all methods inherited from <tt>javax.jdo.spi.PersistenceCapable</tt> (if JDO is on the classpath).
+ */
+public class RemoveJdoEnhancementTypesFacetFactory extends AbstractRemoveMethodsFacetFactory {
+
+ public RemoveJdoEnhancementTypesFacetFactory() {
+ super("javax.jdo.spi.PersistenceCapable");
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/ignore/jdo/RemoveJdoPrefixedMethodsFacetFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/ignore/jdo/RemoveJdoPrefixedMethodsFacetFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/ignore/jdo/RemoveJdoPrefixedMethodsFacetFactory.java
new file mode 100644
index 0000000..8b0565a
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/ignore/jdo/RemoveJdoPrefixedMethodsFacetFactory.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.metamodel.facets.object.ignore.jdo;
+
+
+import java.lang.reflect.Method;
+
+import org.apache.isis.core.metamodel.facetapi.FeatureType;
+import org.apache.isis.core.metamodel.facets.FacetFactoryAbstract;
+
+/**
+ * Removes all methods inherited from <tt>javax.jdo.spi.PersistenceCapable</tt> (if JDO is on the classpath).
+ */
+public class RemoveJdoPrefixedMethodsFacetFactory extends FacetFactoryAbstract {
+
+ public RemoveJdoPrefixedMethodsFacetFactory() {
+ super(FeatureType.OBJECTS_ONLY);
+ }
+
+ @Override
+ public void process(ProcessClassContext context) {
+ Class<?> cls = context.getCls();
+ Method[] methods = cls.getMethods();
+ for(Method method: methods) {
+ if(method.getName().startsWith("jdo")) {
+ context.removeMethod(method);
+ }
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/immutable/ImmutableFacet.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/immutable/ImmutableFacet.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/immutable/ImmutableFacet.java
index e82ed8a..7d6ba57 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/immutable/ImmutableFacet.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/immutable/ImmutableFacet.java
@@ -19,9 +19,10 @@
package org.apache.isis.core.metamodel.facets.object.immutable;
+import org.apache.isis.applib.annotation.When;
import org.apache.isis.core.metamodel.facetapi.FacetHolder;
import org.apache.isis.core.metamodel.facets.WhenValueFacet;
-import org.apache.isis.core.metamodel.facets.ebc.EqualByContentFacet;
+import org.apache.isis.core.metamodel.facets.object.value.EqualByContentFacet;
import org.apache.isis.core.metamodel.facets.object.value.ValueFacet;
import org.apache.isis.core.metamodel.interactions.DisablingInteractionAdvisor;
import org.apache.isis.core.metamodel.spec.ObjectSpecification;
@@ -50,4 +51,34 @@ public interface ImmutableFacet extends WhenValueFacet, DisablingInteractionAdvi
*/
void copyOnto(FacetHolder holder);
+ public final static class Utils {
+
+ private Utils(){}
+ public static boolean isAlwaysImmutable(final ObjectSpecification specification) {
+ // this is a workaround for a dubious test
+ if (specification == null) {
+ return false;
+ }
+
+ final ImmutableFacet immutableFacet = specification.getFacet(ImmutableFacet.class);
+ if (immutableFacet == null) {
+ return false;
+ }
+ return immutableFacet.when() == When.ALWAYS;
+ }
+
+ public static boolean isImmutableOncePersisted(final ObjectSpecification specification) {
+ // this is a workaround for a dubious test
+ if (specification == null) {
+ return false;
+ }
+
+ final ImmutableFacet immutableFacet = specification.getFacet(ImmutableFacet.class);
+ if (immutableFacet == null) {
+ return false;
+ }
+ return immutableFacet.when() == When.ONCE_PERSISTED;
+ }
+
+ }
}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/immutable/ImmutableFacetUtils.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/immutable/ImmutableFacetUtils.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/immutable/ImmutableFacetUtils.java
index 9316bc3..c56a697 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/immutable/ImmutableFacetUtils.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/immutable/ImmutableFacetUtils.java
@@ -19,35 +19,18 @@
package org.apache.isis.core.metamodel.facets.object.immutable;
-import org.apache.isis.applib.annotation.When;
import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-public class ImmutableFacetUtils {
+@Deprecated
+public final class ImmutableFacetUtils {
+ @Deprecated
public static boolean isAlwaysImmutable(final ObjectSpecification specification) {
- // this is a workaround for a dubious test
- if (specification == null) {
- return false;
- }
-
- final ImmutableFacet immutableFacet = specification.getFacet(ImmutableFacet.class);
- if (immutableFacet == null) {
- return false;
- }
- return immutableFacet.when() == When.ALWAYS;
+ return ImmutableFacet.Utils.isAlwaysImmutable(specification);
}
public static boolean isImmutableOncePersisted(final ObjectSpecification specification) {
- // this is a workaround for a dubious test
- if (specification == null) {
- return false;
- }
-
- final ImmutableFacet immutableFacet = specification.getFacet(ImmutableFacet.class);
- if (immutableFacet == null) {
- return false;
- }
- return immutableFacet.when() == When.ONCE_PERSISTED;
+ return ImmutableFacet.Utils.isImmutableOncePersisted(specification);
}
private ImmutableFacetUtils() {
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/immutable/immutableannot/ImmutableFacetAnnotation.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/immutable/immutableannot/ImmutableFacetAnnotation.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/immutable/immutableannot/ImmutableFacetAnnotation.java
new file mode 100644
index 0000000..586a4ad
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/immutable/immutableannot/ImmutableFacetAnnotation.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.immutable.immutableannot;
+
+import org.apache.isis.applib.annotation.When;
+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.facets.object.immutable.ImmutableFacetAbstract;
+
+public class ImmutableFacetAnnotation extends ImmutableFacetAbstract {
+
+ public ImmutableFacetAnnotation(final When value, final FacetHolder holder) {
+ super(value, holder);
+ }
+
+ @Override
+ public void copyOnto(final FacetHolder holder) {
+ final Facet facet = new ImmutableFacetAnnotation(this.when(), holder);
+ FacetUtil.addFacet(facet);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/immutable/immutableannot/ImmutableFacetAnnotationFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/immutable/immutableannot/ImmutableFacetAnnotationFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/immutable/immutableannot/ImmutableFacetAnnotationFactory.java
new file mode 100644
index 0000000..017d6dd
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/immutable/immutableannot/ImmutableFacetAnnotationFactory.java
@@ -0,0 +1,59 @@
+/*
+ * 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.immutable.immutableannot;
+
+import org.apache.isis.applib.annotation.Immutable;
+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.FacetedMethod;
+import org.apache.isis.core.metamodel.facets.object.immutable.ImmutableFacet;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+
+public class ImmutableFacetAnnotationFactory extends FacetFactoryAbstract {
+
+ public ImmutableFacetAnnotationFactory() {
+ super(FeatureType.EVERYTHING_BUT_PARAMETERS);
+ }
+
+ @Override
+ public void process(final ProcessClassContext processClassContaxt) {
+ final Immutable annotation = Annotations.getAnnotation(processClassContaxt.getCls(), Immutable.class);
+ FacetUtil.addFacet(create(annotation, processClassContaxt.getFacetHolder()));
+ }
+
+ @Override
+ public void process(final ProcessMethodContext processMethodContext) {
+ final FacetedMethod member = processMethodContext.getFacetHolder();
+ final Class<?> owningClass = processMethodContext.getCls();
+ final ObjectSpecification owningSpec = getSpecificationLoader().loadSpecification(owningClass);
+ final ImmutableFacet facet = owningSpec.getFacet(ImmutableFacet.class);
+ if (facet != null) {
+ facet.copyOnto(member);
+ }
+ }
+
+ private ImmutableFacet create(final Immutable annotation, final FacetHolder holder) {
+ return annotation == null ? null : new ImmutableFacetAnnotation(annotation.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/immutable/immutablemarkerifc/ImmutableFacetMarkerInterface.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/immutable/immutablemarkerifc/ImmutableFacetMarkerInterface.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/immutable/immutablemarkerifc/ImmutableFacetMarkerInterface.java
new file mode 100644
index 0000000..6e9bbc2
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/immutable/immutablemarkerifc/ImmutableFacetMarkerInterface.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.immutable.immutablemarkerifc;
+
+import org.apache.isis.applib.annotation.When;
+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.facets.object.immutable.ImmutableFacetAbstract;
+
+public class ImmutableFacetMarkerInterface extends ImmutableFacetAbstract {
+
+ public ImmutableFacetMarkerInterface(final When value, final FacetHolder holder) {
+ super(value, holder);
+ }
+
+ @Override
+ public void copyOnto(final FacetHolder holder) {
+ final Facet facet = new ImmutableFacetMarkerInterface(this.when(), holder);
+ FacetUtil.addFacet(facet);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/immutable/immutablemarkerifc/ImmutableFacetMarkerInterfaceFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/immutable/immutablemarkerifc/ImmutableFacetMarkerInterfaceFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/immutable/immutablemarkerifc/ImmutableFacetMarkerInterfaceFactory.java
new file mode 100644
index 0000000..9267681
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/immutable/immutablemarkerifc/ImmutableFacetMarkerInterfaceFactory.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.immutable.immutablemarkerifc;
+
+import org.apache.isis.applib.annotation.When;
+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.object.immutable.ImmutableFacet;
+
+public class ImmutableFacetMarkerInterfaceFactory extends FacetFactoryAbstract {
+
+ public ImmutableFacetMarkerInterfaceFactory() {
+ super(FeatureType.OBJECTS_ONLY);
+ }
+
+ @Override
+ public void process(final ProcessClassContext processClassContext) {
+ final When when = When.lookupForMarkerInterface(processClassContext.getCls());
+ FacetUtil.addFacet(create(when, processClassContext.getFacetHolder()));
+ }
+
+ private ImmutableFacet create(final When when, final FacetHolder holder) {
+ return when == null ? null : new ImmutableFacetMarkerInterface(when, holder);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/mask/MaskEvaluator.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/mask/MaskEvaluator.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/mask/MaskEvaluator.java
new file mode 100644
index 0000000..c6396a3
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/mask/MaskEvaluator.java
@@ -0,0 +1,106 @@
+/*
+ * 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.mask;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Pattern;
+
+public class MaskEvaluator {
+
+ interface Converter {
+ void convert(String str, StringBuilder buf);
+ }
+
+ static class RegExConverter implements Converter {
+ private final String mask;
+ private final String regex;
+
+ public RegExConverter(final String mask, final String regex) {
+ this.mask = mask;
+ this.regex = regex;
+ }
+
+ public String getMask() {
+ return mask;
+ }
+
+ public String getRegex() {
+ return regex;
+ }
+
+ @Override
+ public void convert(final String str, final StringBuilder buf) {
+ final String convert = str.replace(mask, regex);
+ if (!convert.equals(str)) {
+ buf.append(convert);
+ }
+ }
+ }
+
+ @SuppressWarnings("serial")
+ private static List<Converter> converters = new ArrayList<Converter>() {
+ {
+ add("#", "[0-9]");
+ // add(".", "[\\" +
+ // DecimalFormatSymbols.getInstance().getDecimalSeparator()+"]");
+ // add(",",
+ // "["+DecimalFormatSymbols.getInstance().getGroupingSeparator()+"]");
+ add("&", "[A-Za-z]");
+ add("?", "[A-Za-z]");
+ add("A", "[A-Za-z0-9]");
+ add("a", "[ A-Za-z0-9]");
+ add("9", "[ 0-9]");
+ add("U", "[A-Z]");
+ add("L", "[a-z]");
+
+ add(new Converter() {
+ @Override
+ public void convert(final String str, final StringBuilder buf) {
+ if (buf.length() == 0) {
+ buf.append(str);
+ }
+ }
+ });
+ }
+
+ public void add(final String mask, final String regex) {
+ add(new RegExConverter(mask, regex));
+ }
+ };
+
+ private final Pattern pattern;
+
+ public MaskEvaluator(final String mask) {
+ final StringBuilder buf = new StringBuilder();
+ for (int i = 0; i < mask.length(); i++) {
+ final String charAt = "" + mask.charAt(i);
+ for (final Converter converter : converters) {
+ converter.convert(charAt, buf);
+ }
+ }
+ pattern = Pattern.compile(buf.toString());
+ }
+
+ public boolean evaluate(final String str) {
+ return pattern.matcher(str).matches();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/mask/MaskFacet.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/mask/MaskFacet.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/mask/MaskFacet.java
new file mode 100644
index 0000000..298c8af
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/mask/MaskFacet.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.metamodel.facets.object.mask;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.facets.SingleStringValueFacet;
+import org.apache.isis.core.metamodel.interactions.ValidatingInteractionAdvisor;
+import org.apache.isis.core.metamodel.facets.object.regex.RegExFacet;
+
+/**
+ * Whether the (string) property or a parameter must correspond to a specific
+ * mask.
+ *
+ * <p>
+ * In the standard Apache Isis Programming Model, corresponds to the
+ * <tt>@Mask</tt> annotation.
+ *
+ * <p>
+ * TODO: not yet implemented by the framework or any viewer.
+ *
+ * @see RegExFacet
+ */
+public interface MaskFacet extends SingleStringValueFacet, ValidatingInteractionAdvisor {
+
+ /**
+ * Whether the provided string matches the mask.
+ */
+ public boolean doesNotMatch(ObjectAdapter adapter);
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/mask/MaskFacetAbstract.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/mask/MaskFacetAbstract.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/mask/MaskFacetAbstract.java
new file mode 100644
index 0000000..e3878dc
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/mask/MaskFacetAbstract.java
@@ -0,0 +1,53 @@
+/*
+ * 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.mask;
+
+import org.apache.isis.applib.events.ValidityEvent;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.facetapi.Facet;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.SingleStringValueFacetAbstract;
+import org.apache.isis.core.metamodel.interactions.ProposedHolder;
+import org.apache.isis.core.metamodel.interactions.ValidityContext;
+
+public abstract class MaskFacetAbstract extends SingleStringValueFacetAbstract implements MaskFacet {
+
+ public static Class<? extends Facet> type() {
+ return MaskFacet.class;
+ }
+
+ public MaskFacetAbstract(final String value, final FacetHolder holder) {
+ super(type(), holder, value);
+ }
+
+ @Override
+ public String invalidates(final ValidityContext<? extends ValidityEvent> context) {
+ if (!(context instanceof ProposedHolder)) {
+ return null;
+ }
+ final ProposedHolder proposedHolder = (ProposedHolder) context;
+ final ObjectAdapter proposedArgument = proposedHolder.getProposed();
+ if (doesNotMatch(proposedArgument)) {
+ return "'" + proposedArgument.titleString() + "' does not match the mask '" + value() + "'";
+ }
+ return null;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/mask/TitleFacetBasedOnMask.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/mask/TitleFacetBasedOnMask.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/mask/TitleFacetBasedOnMask.java
new file mode 100644
index 0000000..7cba3b8
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/mask/TitleFacetBasedOnMask.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.mask;
+
+import org.apache.isis.applib.profiles.Localization;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.facets.object.title.TitleFacet;
+import org.apache.isis.core.metamodel.facets.object.title.TitleFacetAbstract;
+import org.apache.isis.core.metamodel.facets.object.title.parser.TitleFacetUsingParser;
+
+public class TitleFacetBasedOnMask extends TitleFacetAbstract {
+ private final MaskFacet maskFacet;
+ private final TitleFacet underlyingTitleFacet;
+
+ public TitleFacetBasedOnMask(final MaskFacet maskFacet, final TitleFacet underlyingTitleFacet) {
+ super(maskFacet.getFacetHolder());
+ this.maskFacet = maskFacet;
+ this.underlyingTitleFacet = underlyingTitleFacet;
+ }
+
+ @Override
+ public String title(final ObjectAdapter object, final Localization localization) {
+ final String mask = maskFacet.value();
+ final TitleFacetUsingParser titleFacetUsingParser = (TitleFacetUsingParser) underlyingTitleFacet.getUnderlyingFacet();
+ if (titleFacetUsingParser != null) {
+ final String titleString = titleFacetUsingParser.title(object, mask);
+ return titleString;
+ } else {
+ return underlyingTitleFacet.title(object, localization);
+ }
+ }
+
+}