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:41 UTC
[29/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/properties/interaction/InteractionWithPropertySetterFacetAbstract.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/interaction/InteractionWithPropertySetterFacetAbstract.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/interaction/InteractionWithPropertySetterFacetAbstract.java
index 41d4e71..10bbbbd 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/interaction/InteractionWithPropertySetterFacetAbstract.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/interaction/InteractionWithPropertySetterFacetAbstract.java
@@ -21,30 +21,30 @@ package org.apache.isis.core.metamodel.facets.properties.interaction;
import com.google.common.base.Objects;
import com.google.common.collect.Lists;
-import org.apache.isis.applib.FatalException;
-import org.apache.isis.applib.Identifier;
+import org.apache.isis.applib.services.eventbus.AbstractInteractionEvent;
import org.apache.isis.applib.services.eventbus.PropertyInteractionEvent;
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.facetapi.MultiTypedFacet;
+import org.apache.isis.core.metamodel.facets.InteractionHelper;
import org.apache.isis.core.metamodel.facets.SingleValueFacetAbstract;
-import org.apache.isis.core.metamodel.facets.accessor.PropertyOrCollectionAccessorFacet;
-import org.apache.isis.core.metamodel.facets.properties.modify.PropertySetterFacet;
+import org.apache.isis.core.metamodel.facets.propcoll.accessor.PropertyOrCollectionAccessorFacet;
+import org.apache.isis.core.metamodel.facets.properties.update.modify.PropertySetterFacet;
import org.apache.isis.core.metamodel.runtimecontext.ServicesInjector;
public abstract class InteractionWithPropertySetterFacetAbstract
extends SingleValueFacetAbstract<Class<? extends PropertyInteractionEvent<?,?>>>
implements InteractionWithPropertySetterFacet, MultiTypedFacet {
+
public static Class<? extends Facet> type() {
return PropertySetterFacet.class;
}
private final PropertyOrCollectionAccessorFacet getterFacet;
private final PropertySetterFacet setterFacet;
-
- private final Helper helper;
+ private final InteractionHelper interactionHelper;
public InteractionWithPropertySetterFacetAbstract(
final Class<? extends PropertyInteractionEvent<?, ?>> eventType,
@@ -55,7 +55,7 @@ public abstract class InteractionWithPropertySetterFacetAbstract
super(type(), eventType, holder);
this.getterFacet = getterFacet;
this.setterFacet = setterFacet;
- this.helper = new Helper(servicesInjector);
+ this.interactionHelper = new InteractionHelper(servicesInjector, AbstractInteractionEvent.Mode.EXECUTE);
}
@Override
@@ -63,7 +63,7 @@ public abstract class InteractionWithPropertySetterFacetAbstract
if(setterFacet == null) {
return;
}
- if(helper.getEventBusService() == null) {
+ if(!interactionHelper.hasEventBusService()) {
setterFacet.setProperty(targetAdapter, valueAdapter);
return;
}
@@ -71,33 +71,17 @@ public abstract class InteractionWithPropertySetterFacetAbstract
final Object oldValue = getterFacet.getProperty(targetAdapter);
setterFacet.setProperty(targetAdapter, valueAdapter);
final Object newValue = getterFacet.getProperty(targetAdapter);
- postEventIfChanged(targetAdapter, getIdentified().getIdentifier(), oldValue, newValue);
- }
-
- @SuppressWarnings({ "rawtypes", "unchecked" })
- private void postEventIfChanged(
- final ObjectAdapter targetAdapter,
- final Identifier identifier,
- final Object oldValue,
- final Object newValue) {
if(Objects.equal(oldValue, newValue)) {
// do nothing.
return;
}
- try {
- final Object source = ObjectAdapter.Util.unwrap(targetAdapter);
- final Class type = value();
- final PropertyInteractionEvent<?, ?> event = Util.newEvent(type, source, identifier, oldValue, newValue);
-
- helper.postEvent(event);
- } catch (Exception e) {
- throw new FatalException(e);
- }
+ interactionHelper.postEventForPropertySet(value(), targetAdapter, getIdentified(), oldValue, newValue);
}
+
// //////////////////////////////////////
// MultiTypedFacet
// //////////////////////////////////////
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/mandatory/annotation/mandatory/MandatoryFacetOnPropertyMandatoryAnnotation.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/mandatory/annotation/mandatory/MandatoryFacetOnPropertyMandatoryAnnotation.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/mandatory/annotation/mandatory/MandatoryFacetOnPropertyMandatoryAnnotation.java
new file mode 100644
index 0000000..538dca0
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/mandatory/annotation/mandatory/MandatoryFacetOnPropertyMandatoryAnnotation.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.properties.mandatory.annotation.mandatory;
+
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.propparam.mandatory.MandatoryFacetAbstract;
+
+/**
+ * Derived by presence of an <tt>@Mandatory</tt> annotation.
+ *
+ * <p>
+ * This implementation indicates that the {@link FacetHolder} <i>is</i>
+ * mandatory.
+ */
+public class MandatoryFacetOnPropertyMandatoryAnnotation extends MandatoryFacetAbstract {
+
+ public MandatoryFacetOnPropertyMandatoryAnnotation(final FacetHolder holder) {
+ super(holder, Semantics.REQUIRED);
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/mandatory/annotation/mandatory/MandatoryFacetOnPropertyMandatoryAnnotationFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/mandatory/annotation/mandatory/MandatoryFacetOnPropertyMandatoryAnnotationFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/mandatory/annotation/mandatory/MandatoryFacetOnPropertyMandatoryAnnotationFactory.java
new file mode 100644
index 0000000..1679786
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/mandatory/annotation/mandatory/MandatoryFacetOnPropertyMandatoryAnnotationFactory.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.properties.mandatory.annotation.mandatory;
+
+import org.apache.isis.applib.annotation.Mandatory;
+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.mandatory.MandatoryFacet;
+
+public class MandatoryFacetOnPropertyMandatoryAnnotationFactory extends FacetFactoryAbstract {
+
+ public MandatoryFacetOnPropertyMandatoryAnnotationFactory() {
+ super(FeatureType.PROPERTIES_ONLY);
+ }
+
+ @Override
+ public void process(final ProcessMethodContext processMethodContext) {
+ if (!Annotations.isAnnotationPresent(processMethodContext.getMethod(), Mandatory.class)) {
+ return;
+ }
+ final Mandatory annotation = Annotations.getAnnotation(processMethodContext.getMethod(), Mandatory.class);
+ FacetUtil.addFacet(create(annotation, processMethodContext.getFacetHolder()));
+ }
+
+ private MandatoryFacet create(final Mandatory annotation, final FacetHolder holder) {
+ return annotation != null ? new MandatoryFacetOnPropertyMandatoryAnnotation(holder) : null;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/mandatory/annotation/optional/MandatoryFacetOnPropertyInvertedByOptionalAnnotation.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/mandatory/annotation/optional/MandatoryFacetOnPropertyInvertedByOptionalAnnotation.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/mandatory/annotation/optional/MandatoryFacetOnPropertyInvertedByOptionalAnnotation.java
new file mode 100644
index 0000000..083e250
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/mandatory/annotation/optional/MandatoryFacetOnPropertyInvertedByOptionalAnnotation.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.properties.mandatory.annotation.optional;
+
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.propparam.mandatory.MandatoryFacetAbstract;
+
+/**
+ * Derived by presence of an <tt>@Optional</tt> annotation.
+ *
+ * <p>
+ * This implementation indicates that the {@link FacetHolder} is <i>not</i>
+ * mandatory, as per {@link #isInvertedSemantics()}.
+ */
+public class MandatoryFacetOnPropertyInvertedByOptionalAnnotation extends MandatoryFacetAbstract {
+
+ public MandatoryFacetOnPropertyInvertedByOptionalAnnotation(final FacetHolder holder) {
+ super(holder, Semantics.OPTIONAL);
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/mandatory/annotation/optional/MandatoryFacetOnPropertyInvertedByOptionalAnnotationFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/mandatory/annotation/optional/MandatoryFacetOnPropertyInvertedByOptionalAnnotationFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/mandatory/annotation/optional/MandatoryFacetOnPropertyInvertedByOptionalAnnotationFactory.java
new file mode 100644
index 0000000..aef6b79
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/mandatory/annotation/optional/MandatoryFacetOnPropertyInvertedByOptionalAnnotationFactory.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.properties.mandatory.annotation.optional;
+
+import org.apache.isis.applib.annotation.Optional;
+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.mandatory.MandatoryFacet;
+
+public class MandatoryFacetOnPropertyInvertedByOptionalAnnotationFactory extends FacetFactoryAbstract {
+
+ public MandatoryFacetOnPropertyInvertedByOptionalAnnotationFactory() {
+ super(FeatureType.PROPERTIES_ONLY);
+ }
+
+ @Override
+ public void process(final ProcessMethodContext processMethodContext) {
+ final Class<?> returnType = processMethodContext.getMethod().getReturnType();
+ if (returnType.isPrimitive()) {
+ return;
+ }
+ if (!Annotations.isAnnotationPresent(processMethodContext.getMethod(), Optional.class)) {
+ return;
+ }
+ final Optional annotation = Annotations.getAnnotation(processMethodContext.getMethod(), Optional.class);
+ FacetUtil.addFacet(create(annotation, processMethodContext.getFacetHolder()));
+ }
+
+ private MandatoryFacet create(final Optional annotation, final FacetHolder holder) {
+ return annotation != null ? new MandatoryFacetOnPropertyInvertedByOptionalAnnotation(holder) : null;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/mandatory/dflt/MandatoryFacetOnProperyDefaultFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/mandatory/dflt/MandatoryFacetOnProperyDefaultFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/mandatory/dflt/MandatoryFacetOnProperyDefaultFactory.java
new file mode 100644
index 0000000..9e0c8ed
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/mandatory/dflt/MandatoryFacetOnProperyDefaultFactory.java
@@ -0,0 +1,57 @@
+/*
+ * 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.properties.mandatory.dflt;
+
+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.FacetFactory;
+import org.apache.isis.core.metamodel.facets.FacetFactoryAbstract;
+import org.apache.isis.core.metamodel.facets.propparam.mandatory.MandatoryFacet;
+import org.apache.isis.core.metamodel.facets.propparam.mandatory.MandatoryFacetDefault;
+import org.apache.isis.core.metamodel.specloader.facetprocessor.FacetProcessor;
+
+/**
+ * Simply installs a {@link MandatoryFacetDefault} onto all properties and
+ * parameters.
+ *
+ * <p>
+ * The idea is that this {@link FacetFactory} is included early on in the
+ * {@link FacetProcessor}, but other {@link MandatoryFacet} implementations
+ * which don't require mandatory semantics will potentially replace these where
+ * the property or parameter is annotated or otherwise indicated as being
+ * optional.
+ */
+public class MandatoryFacetOnProperyDefaultFactory extends FacetFactoryAbstract {
+
+ public MandatoryFacetOnProperyDefaultFactory() {
+ super(FeatureType.PROPERTIES_ONLY);
+ }
+
+ @Override
+ public void process(final ProcessMethodContext processMethodContext) {
+ FacetUtil.addFacet(create(processMethodContext.getFacetHolder()));
+ }
+
+ private MandatoryFacet create(final FacetHolder holder) {
+ return new MandatoryFacetDefault(holder);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/mandatory/staticmethod/MandatoryFacetOnPropertyStaticMethod.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/mandatory/staticmethod/MandatoryFacetOnPropertyStaticMethod.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/mandatory/staticmethod/MandatoryFacetOnPropertyStaticMethod.java
new file mode 100644
index 0000000..0de913f
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/mandatory/staticmethod/MandatoryFacetOnPropertyStaticMethod.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.properties.mandatory.staticmethod;
+
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.propparam.mandatory.MandatoryFacetAbstract;
+
+/**
+ * Derived by presence of an <tt>optionalXxx</tt> method.
+ *
+ * <p>
+ * This implementation indicates that the {@link FacetHolder} is <i>not</i>
+ * mandatory, as per {@link #isInvertedSemantics()}.
+ */
+public class MandatoryFacetOnPropertyStaticMethod extends MandatoryFacetAbstract {
+
+ public MandatoryFacetOnPropertyStaticMethod(final FacetHolder holder) {
+ super(holder, Semantics.OPTIONAL);
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/mandatory/staticmethod/MandatoryFacetOnPropertyStaticMethodFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/mandatory/staticmethod/MandatoryFacetOnPropertyStaticMethodFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/mandatory/staticmethod/MandatoryFacetOnPropertyStaticMethodFactory.java
new file mode 100644
index 0000000..5e09236
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/mandatory/staticmethod/MandatoryFacetOnPropertyStaticMethodFactory.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.properties.mandatory.staticmethod;
+
+import java.lang.reflect.Method;
+
+import org.apache.isis.core.commons.lang.MethodExtensions;
+import org.apache.isis.core.commons.lang.StringExtensions;
+import org.apache.isis.core.metamodel.exceptions.MetaModelException;
+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 MandatoryFacetOnPropertyStaticMethodFactory extends MethodPrefixBasedFacetFactoryAbstract {
+
+ private static final String[] PREFIXES = { MethodPrefixConstants.OPTIONAL_PREFIX };
+
+ public MandatoryFacetOnPropertyStaticMethodFactory() {
+ super(FeatureType.PROPERTIES_ONLY, OrphanValidation.VALIDATE, PREFIXES);
+ }
+
+ @Override
+ public void process(final ProcessMethodContext processMethodContext) {
+
+ attachMandatoryFacetIfOptionalMethodIsFound(processMethodContext);
+ }
+
+ private static void attachMandatoryFacetIfOptionalMethodIsFound(final ProcessMethodContext processMethodContext) {
+ final Method method = processMethodContext.getMethod();
+
+ final String capitalizedName = StringExtensions.asJavaBaseName(method.getName());
+ final Class<?> returnType = method.getReturnType();
+
+ final Class<?> cls = processMethodContext.getCls();
+ final Method optionalMethod = MethodFinderUtils.findMethod(cls, MethodScope.CLASS, MethodPrefixConstants.OPTIONAL_PREFIX + capitalizedName, boolean.class, NO_PARAMETERS_TYPES);
+ processMethodContext.removeMethod(optionalMethod);
+
+ if (!indicatesOptional(optionalMethod)) {
+ return;
+ }
+ if (returnType.isPrimitive()) {
+ throw new MetaModelException(cls.getName() + "#" + capitalizedName + " cannot be an optional property as it is of a primitive type");
+ }
+ final FacetHolder property = processMethodContext.getFacetHolder();
+ FacetUtil.addFacet(new MandatoryFacetOnPropertyStaticMethod(property));
+ }
+
+ private static boolean indicatesOptional(final Method method) {
+ if (method != null) {
+ Boolean optionalMethodReturnValue = null;
+ try {
+ optionalMethodReturnValue = (Boolean) MethodExtensions.invoke(method, new Object[0]);
+ } catch (final ClassCastException ex) {
+ // ignore
+ }
+ if (optionalMethodReturnValue == null) {
+ throw new MetaModelException("method " + method + " should return a boolean");
+ }
+ return optionalMethodReturnValue.booleanValue();
+ }
+ return false;
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/modify/PropertyClearFacet.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/modify/PropertyClearFacet.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/modify/PropertyClearFacet.java
deleted file mode 100644
index 3e6e1e6..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/modify/PropertyClearFacet.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 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.properties.modify;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.facetapi.Facet;
-
-/**
- * Mechanism for clearing a property of an object (that is, setting it to
- * <tt>null</tt>).
- *
- * <p>
- * In the standard Apache Isis Programming Model, typically corresponds to a
- * method named <tt>clearXxx</tt> (for a property <tt>getXxx</tt>). As a
- * fallback the standard model also supports invoking the <tt>setXxx</tt> method
- * with <tt>null</tt>.
- */
-public interface PropertyClearFacet extends Facet {
-
- public void clearProperty(ObjectAdapter inObject);
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/modify/PropertyClearFacetAbstract.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/modify/PropertyClearFacetAbstract.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/modify/PropertyClearFacetAbstract.java
deleted file mode 100644
index 1fe63cb..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/modify/PropertyClearFacetAbstract.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * 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.properties.modify;
-
-import org.apache.isis.core.metamodel.facetapi.Facet;
-import org.apache.isis.core.metamodel.facetapi.FacetAbstract;
-import org.apache.isis.core.metamodel.facetapi.FacetHolder;
-
-public abstract class PropertyClearFacetAbstract extends FacetAbstract implements PropertyClearFacet {
-
- public static Class<? extends Facet> type() {
- return PropertyClearFacet.class;
- }
-
- public PropertyClearFacetAbstract(final FacetHolder holder) {
- super(type(), holder, Derivation.NOT_DERIVED);
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/modify/PropertyInitializationFacet.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/modify/PropertyInitializationFacet.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/modify/PropertyInitializationFacet.java
deleted file mode 100644
index 809b040..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/modify/PropertyInitializationFacet.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * 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.properties.modify;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.facetapi.Facet;
-import org.apache.isis.core.metamodel.facets.accessor.PropertyOrCollectionAccessorFacet;
-
-/**
- * The mechanism by which the value of the property can be initialised.
- *
- * <p>
- * This differs from the {@link PropertySetterFacet} in that it is only called
- * when object is set up (after persistence) and not every time a property
- * changes; hence it will not be made part of a transaction.
- *
- * <p>
- * In the standard Apache Isis Programming Model, corresponds to invoking the
- * mutator method for a property.
- *
- * @see PropertyOrCollectionAccessorFacet
- * @see PropertySetterFacet
- * @see PropertyClearFacet
- */
-public interface PropertyInitializationFacet extends Facet {
-
- /**
- * Sets the value of this property.
- */
- public void initProperty(ObjectAdapter inObject, ObjectAdapter value);
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/modify/PropertySetterFacet.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/modify/PropertySetterFacet.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/modify/PropertySetterFacet.java
deleted file mode 100644
index 951da4a..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/modify/PropertySetterFacet.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * 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.properties.modify;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.facetapi.Facet;
-import org.apache.isis.core.metamodel.facets.accessor.PropertyOrCollectionAccessorFacet;
-
-/**
- * The mechanism by which the value of the property can be set.
- *
- * <p>
- * In the standard Apache Isis Programming Model, corresponds to invoking the
- * mutator method for a property.
- *
- * @see PropertyOrCollectionAccessorFacet
- * @see PropertyClearFacet
- * @see PropertyInitializationFacet
- */
-public interface PropertySetterFacet extends Facet {
-
- /**
- * Sets the value of this property.
- */
- public void setProperty(ObjectAdapter inObject, ObjectAdapter value);
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/modify/PropertySetterFacetAbstract.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/modify/PropertySetterFacetAbstract.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/modify/PropertySetterFacetAbstract.java
deleted file mode 100644
index fd22298..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/modify/PropertySetterFacetAbstract.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * 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.properties.modify;
-
-import org.apache.isis.core.metamodel.facetapi.Facet;
-import org.apache.isis.core.metamodel.facetapi.FacetAbstract;
-import org.apache.isis.core.metamodel.facetapi.FacetHolder;
-
-public abstract class PropertySetterFacetAbstract extends FacetAbstract implements PropertySetterFacet {
-
- public static Class<? extends Facet> type() {
- return PropertySetterFacet.class;
- }
-
- public PropertySetterFacetAbstract(final FacetHolder holder) {
- super(type(), holder, Derivation.NOT_DERIVED);
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/multiline/annotation/MultiLineFacetOnPropertyAnnotation.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/multiline/annotation/MultiLineFacetOnPropertyAnnotation.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/multiline/annotation/MultiLineFacetOnPropertyAnnotation.java
new file mode 100644
index 0000000..30f0d68
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/multiline/annotation/MultiLineFacetOnPropertyAnnotation.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.properties.multiline.annotation;
+
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.propparam.multiline.MultiLineFacetAbstract;
+
+public class MultiLineFacetOnPropertyAnnotation extends MultiLineFacetAbstract {
+
+ public MultiLineFacetOnPropertyAnnotation(final int numberOfLines, final boolean preventWrapping, final FacetHolder holder) {
+ super(numberOfLines, preventWrapping, holder);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/multiline/annotation/MultiLineFacetOnPropertyFromProperties.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/multiline/annotation/MultiLineFacetOnPropertyFromProperties.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/multiline/annotation/MultiLineFacetOnPropertyFromProperties.java
new file mode 100644
index 0000000..1c9410b
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/multiline/annotation/MultiLineFacetOnPropertyFromProperties.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.core.metamodel.facets.properties.multiline.annotation;
+
+import java.util.Properties;
+
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.propparam.multiline.MultiLineFacetAbstract;
+
+public class MultiLineFacetOnPropertyFromProperties extends MultiLineFacetAbstract {
+
+ public MultiLineFacetOnPropertyFromProperties(Properties properties, FacetHolder holder) {
+ super(numberOfLinesFrom(properties), preventWrappingFrom(properties), holder);
+ }
+
+ private static int numberOfLinesFrom(Properties properties) {
+ return Integer.parseInt(properties.getProperty("numberOfLines"));
+ }
+
+ private static boolean preventWrappingFrom(Properties properties) {
+ final String property = properties.getProperty("preventWrapping");
+ // same defaults as @MultiLine annotation
+ return property == null || Boolean.parseBoolean(property);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/multiline/annotation/MultiLineOnPropertyFacetFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/multiline/annotation/MultiLineOnPropertyFacetFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/multiline/annotation/MultiLineOnPropertyFacetFactory.java
new file mode 100644
index 0000000..50b9e63
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/multiline/annotation/MultiLineOnPropertyFacetFactory.java
@@ -0,0 +1,74 @@
+/*
+ * 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.properties.multiline.annotation;
+
+import java.util.Properties;
+
+import org.apache.isis.applib.annotation.MultiLine;
+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.ContributeeMemberFacetFactory;
+import org.apache.isis.core.metamodel.facets.FacetFactoryAbstract;
+import org.apache.isis.core.metamodel.facets.propparam.multiline.MultiLineFacet;
+
+public class MultiLineOnPropertyFacetFactory extends FacetFactoryAbstract implements ContributeeMemberFacetFactory {
+
+ public MultiLineOnPropertyFacetFactory() {
+ super(FeatureType.PROPERTIES_ONLY);
+ }
+
+ @Override
+ public void process(final ProcessMethodContext processMethodContext) {
+ MultiLineFacet facet = createFromMetadataPropertiesIfPossible(processMethodContext);
+ if(facet == null) {
+ facet = createFromAnnotationIfPossible(processMethodContext);
+ }
+
+ // no-op if null
+ FacetUtil.addFacet(facet);
+ }
+
+ @Override
+ public void process(ProcessContributeeMemberContext processMemberContext) {
+
+ }
+
+ private static MultiLineFacet createFromMetadataPropertiesIfPossible(
+ final ProcessContextWithMetadataProperties<? extends FacetHolder> pcwmp) {
+
+ final FacetHolder holder = pcwmp.getFacetHolder();
+
+ final Properties properties = pcwmp.metadataProperties("multiLine");
+ return properties != null ? new MultiLineFacetOnPropertyFromProperties(properties, holder) : null;
+ }
+
+ private static MultiLineFacetOnPropertyAnnotation createFromAnnotationIfPossible(final ProcessMethodContext processMethodContext) {
+ final Class<?> returnType = processMethodContext.getMethod().getReturnType();
+ if (!Annotations.isString(returnType)) {
+ return null;
+ }
+ final MultiLine annotation = Annotations.getAnnotation(processMethodContext.getMethod(), MultiLine.class);
+ return (annotation != null) ? new MultiLineFacetOnPropertyAnnotation(annotation.numberOfLines(), annotation.preventWrapping(), processMethodContext.getFacetHolder()) : null;
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/notpersisted/annotation/NotPersistedFacetOnPropertyAnnotation.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/notpersisted/annotation/NotPersistedFacetOnPropertyAnnotation.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/notpersisted/annotation/NotPersistedFacetOnPropertyAnnotation.java
new file mode 100644
index 0000000..e15e8a6
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/notpersisted/annotation/NotPersistedFacetOnPropertyAnnotation.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.properties.notpersisted.annotation;
+
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.propcoll.notpersisted.NotPersistedFacetAbstract;
+
+public class NotPersistedFacetOnPropertyAnnotation extends NotPersistedFacetAbstract {
+
+ public NotPersistedFacetOnPropertyAnnotation(final FacetHolder holder) {
+ super(holder);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/notpersisted/annotation/NotPersistedFacetOnPropertyAnnotationFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/notpersisted/annotation/NotPersistedFacetOnPropertyAnnotationFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/notpersisted/annotation/NotPersistedFacetOnPropertyAnnotationFactory.java
new file mode 100644
index 0000000..a4f2ff0
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/notpersisted/annotation/NotPersistedFacetOnPropertyAnnotationFactory.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.properties.notpersisted.annotation;
+
+import org.apache.isis.applib.annotation.NotPersisted;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facetapi.FacetUtil;
+import org.apache.isis.core.metamodel.facetapi.FeatureType;
+import org.apache.isis.core.metamodel.facets.Annotations;
+import org.apache.isis.core.metamodel.facets.FacetFactoryAbstract;
+import org.apache.isis.core.metamodel.facets.propcoll.notpersisted.NotPersistedFacet;
+
+public class NotPersistedFacetOnPropertyAnnotationFactory extends FacetFactoryAbstract {
+
+ public NotPersistedFacetOnPropertyAnnotationFactory() {
+ super(FeatureType.PROPERTIES_ONLY);
+ }
+
+ @Override
+ public void process(final ProcessMethodContext processMethodContext) {
+ final NotPersisted annotation = Annotations.getAnnotation(processMethodContext.getMethod(), NotPersisted.class);
+ FacetUtil.addFacet(create(annotation, processMethodContext.getFacetHolder()));
+ }
+
+ private NotPersistedFacet create(final NotPersisted annotation, final FacetHolder holder) {
+ return annotation == null ? null : new NotPersistedFacetOnPropertyAnnotation(holder);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/renderedasdaybefore/annotation/RenderedAsDayBeforeAnnotationOnPropertyFacetFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/renderedasdaybefore/annotation/RenderedAsDayBeforeAnnotationOnPropertyFacetFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/renderedasdaybefore/annotation/RenderedAsDayBeforeAnnotationOnPropertyFacetFactory.java
new file mode 100644
index 0000000..b3edbda
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/renderedasdaybefore/annotation/RenderedAsDayBeforeAnnotationOnPropertyFacetFactory.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.properties.renderedasdaybefore.annotation;
+
+import org.apache.isis.applib.annotation.RenderedAsDayBefore;
+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.renderedadjusted.RenderedAdjustedFacet;
+
+public class RenderedAsDayBeforeAnnotationOnPropertyFacetFactory extends FacetFactoryAbstract {
+
+ public RenderedAsDayBeforeAnnotationOnPropertyFacetFactory() {
+ super(FeatureType.PROPERTIES_ONLY);
+ }
+
+ @Override
+ public void process(final ProcessMethodContext processMethodContext) {
+ final RenderedAsDayBefore annotation = Annotations.getAnnotation(processMethodContext.getMethod(), RenderedAsDayBefore.class);
+ final RenderedAdjustedFacet facet = create(annotation, processMethodContext.getFacetHolder());
+
+ FacetUtil.addFacet(facet);
+ }
+
+ private RenderedAdjustedFacet create(final RenderedAsDayBefore annotation, final FacetHolder holder) {
+ return annotation != null ? new RenderedAsDayBeforeFacetAnnotationOnProperty(holder) : null;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/renderedasdaybefore/annotation/RenderedAsDayBeforeFacetAnnotationOnProperty.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/renderedasdaybefore/annotation/RenderedAsDayBeforeFacetAnnotationOnProperty.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/renderedasdaybefore/annotation/RenderedAsDayBeforeFacetAnnotationOnProperty.java
new file mode 100644
index 0000000..03f9764
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/renderedasdaybefore/annotation/RenderedAsDayBeforeFacetAnnotationOnProperty.java
@@ -0,0 +1,38 @@
+/*
+ * 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.properties.renderedasdaybefore.annotation;
+
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.propparam.renderedadjusted.RenderedAdjustedFacetAbstract;
+
+public class RenderedAsDayBeforeFacetAnnotationOnProperty extends RenderedAdjustedFacetAbstract {
+
+ private static final int ADJUST_BY = -1;
+
+ public RenderedAsDayBeforeFacetAnnotationOnProperty(final FacetHolder holder) {
+ super(holder, false);
+ }
+
+ @Override
+ public int value() {
+ return ADJUST_BY;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/typicallen/annotation/TypicalLengthFacetOnPropertyAnnotation.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/typicallen/annotation/TypicalLengthFacetOnPropertyAnnotation.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/typicallen/annotation/TypicalLengthFacetOnPropertyAnnotation.java
new file mode 100644
index 0000000..ed10e25
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/typicallen/annotation/TypicalLengthFacetOnPropertyAnnotation.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.properties.typicallen.annotation;
+
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.objpropparam.typicallen.TypicalLengthFacetAbstract;
+
+public class TypicalLengthFacetOnPropertyAnnotation extends TypicalLengthFacetAbstract {
+
+ private final int value;
+
+ public TypicalLengthFacetOnPropertyAnnotation(final int value, final FacetHolder holder) {
+ super(holder, false);
+ this.value = value;
+ }
+
+ @Override
+ public int value() {
+ return value;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/typicallen/annotation/TypicalLengthFacetOnPropertyFromProperties.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/typicallen/annotation/TypicalLengthFacetOnPropertyFromProperties.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/typicallen/annotation/TypicalLengthFacetOnPropertyFromProperties.java
new file mode 100644
index 0000000..6f0b311
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/typicallen/annotation/TypicalLengthFacetOnPropertyFromProperties.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.properties.typicallen.annotation;
+
+import java.util.Properties;
+
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.objpropparam.typicallen.TypicalLengthFacetAbstract;
+
+public class TypicalLengthFacetOnPropertyFromProperties extends TypicalLengthFacetAbstract {
+
+ private final int value;
+
+ public TypicalLengthFacetOnPropertyFromProperties(final Properties properties, final FacetHolder holder) {
+ super(holder, false);
+ this.value = Integer.parseInt(properties.getProperty("value"));
+ }
+
+ @Override
+ public int value() {
+ return value;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/typicallen/annotation/TypicalLengthOnPropertyFacetFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/typicallen/annotation/TypicalLengthOnPropertyFacetFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/typicallen/annotation/TypicalLengthOnPropertyFacetFactory.java
new file mode 100644
index 0000000..b8d2a62
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/typicallen/annotation/TypicalLengthOnPropertyFacetFactory.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.properties.typicallen.annotation;
+
+import java.util.Properties;
+
+import org.apache.isis.applib.annotation.TypicalLength;
+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.ContributeeMemberFacetFactory;
+import org.apache.isis.core.metamodel.facets.FacetFactoryAbstract;
+import org.apache.isis.core.metamodel.facets.objpropparam.typicallen.TypicalLengthFacet;
+
+public class TypicalLengthOnPropertyFacetFactory extends FacetFactoryAbstract implements ContributeeMemberFacetFactory {
+
+ public TypicalLengthOnPropertyFacetFactory() {
+ super(FeatureType.PROPERTIES_ONLY);
+ }
+
+ @Override
+ public void process(final ProcessMethodContext processMethodContext) {
+ TypicalLengthFacet facet = createFromMetadataPropertiesIfPossible(processMethodContext);
+ if(facet == null) {
+ facet = createFromAnnotationIfPossible(processMethodContext);
+ }
+
+ // no-op if null
+ FacetUtil.addFacet(facet);
+ }
+
+ @Override
+ public void process(ProcessContributeeMemberContext processMemberContext) {
+ TypicalLengthFacet facet = createFromMetadataPropertiesIfPossible(processMemberContext);
+
+ // no-op if null
+ FacetUtil.addFacet(facet);
+ }
+
+ private static TypicalLengthFacet createFromMetadataPropertiesIfPossible(
+ final ProcessContextWithMetadataProperties<? extends FacetHolder> pcwmp) {
+
+ final FacetHolder holder = pcwmp.getFacetHolder();
+
+ final Properties properties = pcwmp.metadataProperties("typicalLength");
+ return properties != null ? new TypicalLengthFacetOnPropertyFromProperties(properties, holder) : null;
+ }
+
+ private static TypicalLengthFacet createFromAnnotationIfPossible(final ProcessMethodContext processMethodContext) {
+ final TypicalLength annotation =
+ Annotations.getAnnotation(processMethodContext.getMethod(), TypicalLength.class);
+ return annotation != null
+ ? new TypicalLengthFacetOnPropertyAnnotation(annotation.value(), processMethodContext.getFacetHolder())
+ : null;
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/typicallen/fromtype/TypicalLengthFacetOnPropertyDerivedFromType.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/typicallen/fromtype/TypicalLengthFacetOnPropertyDerivedFromType.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/typicallen/fromtype/TypicalLengthFacetOnPropertyDerivedFromType.java
new file mode 100644
index 0000000..197a572
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/typicallen/fromtype/TypicalLengthFacetOnPropertyDerivedFromType.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.properties.typicallen.fromtype;
+
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.propparam.multiline.MultiLineFacet;
+import org.apache.isis.core.metamodel.facets.objpropparam.typicallen.TypicalLengthFacet;
+import org.apache.isis.core.metamodel.facets.objpropparam.typicallen.TypicalLengthFacetAbstract;
+
+public class TypicalLengthFacetOnPropertyDerivedFromType extends TypicalLengthFacetAbstract {
+
+ private final TypicalLengthFacet typicalLengthFacet;
+
+ public TypicalLengthFacetOnPropertyDerivedFromType(final TypicalLengthFacet typicalLengthFacet, final FacetHolder holder) {
+ super(holder, true);
+ this.typicalLengthFacet = typicalLengthFacet;
+ }
+
+ @Override
+ public int value() {
+ final MultiLineFacet facet = getFacetHolder().getFacet(MultiLineFacet.class);
+ return facet.numberOfLines() * typicalLengthFacet.value();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/typicallen/fromtype/TypicalLengthFacetOnPropertyDerivedFromTypeFacetFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/typicallen/fromtype/TypicalLengthFacetOnPropertyDerivedFromTypeFacetFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/typicallen/fromtype/TypicalLengthFacetOnPropertyDerivedFromTypeFacetFactory.java
new file mode 100644
index 0000000..cab1cca
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/typicallen/fromtype/TypicalLengthFacetOnPropertyDerivedFromTypeFacetFactory.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.properties.typicallen.fromtype;
+
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facetapi.FacetUtil;
+import org.apache.isis.core.metamodel.facetapi.FeatureType;
+import org.apache.isis.core.metamodel.facets.FacetFactoryAbstract;
+import org.apache.isis.core.metamodel.facets.FacetedMethod;
+import org.apache.isis.core.metamodel.facets.objpropparam.typicallen.TypicalLengthFacet;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+
+public class TypicalLengthFacetOnPropertyDerivedFromTypeFacetFactory extends FacetFactoryAbstract {
+
+ public TypicalLengthFacetOnPropertyDerivedFromTypeFacetFactory() {
+ super(FeatureType.PROPERTIES_ONLY);
+ }
+
+ @Override
+ public void process(final ProcessMethodContext processMethodContext) {
+ final Class<?> type = processMethodContext.getMethod().getReturnType();
+ final FacetedMethod facetHolder = processMethodContext.getFacetHolder();
+ addFacetDerivedFromTypeIfPresent(facetHolder, type);
+ }
+
+ private void addFacetDerivedFromTypeIfPresent(final FacetHolder holder, final Class<?> type) {
+ final TypicalLengthFacet facet = getTypicalLengthFacet(type);
+ if (facet != null) {
+ FacetUtil.addFacet(new TypicalLengthFacetOnPropertyDerivedFromType(facet, holder));
+ }
+ }
+
+ private TypicalLengthFacet getTypicalLengthFacet(final Class<?> type) {
+ final ObjectSpecification paramTypeSpec = getSpecificationLoader().loadSpecification(type);
+ return paramTypeSpec.getFacet(TypicalLengthFacet.class);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/update/NotPersistableFacetInferred.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/update/NotPersistableFacetInferred.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/update/NotPersistableFacetInferred.java
new file mode 100644
index 0000000..a7942da
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/update/NotPersistableFacetInferred.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.properties.update;
+
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.propcoll.notpersisted.NotPersistedFacetAbstract;
+
+public class NotPersistableFacetInferred extends NotPersistedFacetAbstract {
+
+ public NotPersistableFacetInferred(final FacetHolder holder) {
+ super(holder);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/update/PropertyModifyFacetFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/update/PropertyModifyFacetFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/update/PropertyModifyFacetFactory.java
new file mode 100644
index 0000000..c0f278b
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/update/PropertyModifyFacetFactory.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.properties.update;
+
+import java.lang.reflect.Method;
+
+import org.apache.isis.core.commons.lang.StringExtensions;
+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.properties.update.modify.PropertySetterFacetViaModifyMethod;
+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 PropertyModifyFacetFactory extends MethodPrefixBasedFacetFactoryAbstract {
+
+ private static final String[] PREFIXES = { MethodPrefixConstants.MODIFY_PREFIX };
+
+ public PropertyModifyFacetFactory() {
+ super(FeatureType.PROPERTIES_ONLY, OrphanValidation.VALIDATE, PREFIXES);
+ }
+
+ @Override
+ public void process(final ProcessMethodContext processMethodContext) {
+
+ attachPropertyModifyFacetIfModifyMethodIsFound(processMethodContext);
+ }
+
+ private void attachPropertyModifyFacetIfModifyMethodIsFound(final ProcessMethodContext processMethodContext) {
+
+ final Method getMethod = processMethodContext.getMethod();
+ final String capitalizedName = StringExtensions.asJavaBaseName(getMethod.getName());
+
+ final Class<?> returnType = getMethod.getReturnType();
+ final Class<?>[] paramTypes = new Class[] { returnType };
+
+ final Class<?> cls = processMethodContext.getCls();
+ final Method modifyMethod = MethodFinderUtils.findMethod(cls, MethodScope.OBJECT, MethodPrefixConstants.MODIFY_PREFIX + capitalizedName, void.class, paramTypes);
+
+ if (modifyMethod == null) {
+ return;
+ }
+ processMethodContext.removeMethod(modifyMethod);
+
+ final FacetHolder property = processMethodContext.getFacetHolder();
+ FacetUtil.addFacet(new PropertySetterFacetViaModifyMethod(modifyMethod, property));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/update/PropertySetAndClearFacetFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/update/PropertySetAndClearFacetFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/update/PropertySetAndClearFacetFactory.java
new file mode 100644
index 0000000..ebae38d
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/update/PropertySetAndClearFacetFactory.java
@@ -0,0 +1,116 @@
+/*
+ * 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.properties.update;
+
+import java.lang.reflect.Method;
+
+import org.apache.isis.core.commons.lang.StringExtensions;
+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.notpersistable.NotPersistableFacet;
+import org.apache.isis.core.metamodel.facets.properties.update.clear.PropertyClearFacetViaClearMethod;
+import org.apache.isis.core.metamodel.facets.properties.update.clear.PropertyClearFacetViaSetterMethod;
+import org.apache.isis.core.metamodel.facets.properties.update.init.PropertyInitializationFacetViaSetterMethod;
+import org.apache.isis.core.metamodel.facets.properties.update.modify.PropertySetterFacetViaSetterMethod;
+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;
+import org.apache.isis.core.metamodel.facets.members.disabled.DisabledFacet;
+import org.apache.isis.core.metamodel.facets.members.disabled.DisabledFacetAlwaysEverywhere;
+
+public class PropertySetAndClearFacetFactory extends MethodPrefixBasedFacetFactoryAbstract {
+
+ private static final String[] PREFIXES = { MethodPrefixConstants.SET_PREFIX, MethodPrefixConstants.CLEAR_PREFIX };
+
+ public PropertySetAndClearFacetFactory() {
+ super(FeatureType.PROPERTIES_ONLY, OrphanValidation.VALIDATE, PREFIXES);
+ }
+
+ @Override
+ public void process(final ProcessMethodContext processMethodContext) {
+
+ final Method setMethod = attachPropertyModifyFacetIfSetterIsFound(processMethodContext);
+ final Method clearMethod = attachPropertyClearFacetIfClearMethodIsFound(processMethodContext);
+
+ attachPropertyClearFacetUsingSetterIfRequired(processMethodContext, setMethod, clearMethod);
+ }
+
+ /**
+ * Sets up the {@link org.apache.isis.core.metamodel.facets.properties.update.modify.PropertySetterFacetViaSetterMethod} to invoke the
+ * property's setter if available, but if none then marks the property as
+ * {@link NotPersistableFacet not-persistable} and {@link DisabledFacet
+ * disabled} otherwise.
+ */
+ private static Method attachPropertyModifyFacetIfSetterIsFound(final ProcessMethodContext processMethodContext) {
+
+ final Method getMethod = processMethodContext.getMethod();
+ final String capitalizedName = StringExtensions.asJavaBaseName(getMethod.getName());
+
+ final Class<?> cls = processMethodContext.getCls();
+ final Class<?> returnType = getMethod.getReturnType();
+ final Class<?>[] paramTypes = new Class[] { returnType };
+ final Method setMethod = MethodFinderUtils.findMethod(cls, MethodScope.OBJECT, MethodPrefixConstants.SET_PREFIX + capitalizedName, void.class, paramTypes);
+ processMethodContext.removeMethod(setMethod);
+
+ final FacetHolder property = processMethodContext.getFacetHolder();
+ if (setMethod != null) {
+ FacetUtil.addFacet(new PropertySetterFacetViaSetterMethod(setMethod, property));
+ FacetUtil.addFacet(new PropertyInitializationFacetViaSetterMethod(setMethod, property));
+ } else {
+ FacetUtil.addFacet(new NotPersistableFacetInferred(property));
+ FacetUtil.addFacet(new DisabledFacetAlwaysEverywhere(property));
+ }
+
+ return setMethod;
+ }
+
+ private Method attachPropertyClearFacetIfClearMethodIsFound(final ProcessMethodContext processMethodContext) {
+ final Class<?> cls = processMethodContext.getCls();
+ final Method getMethod = processMethodContext.getMethod();
+ final FacetHolder property = processMethodContext.getFacetHolder();
+
+ final String capitalizedName = StringExtensions.asJavaBaseName(getMethod.getName());
+ final Method clearMethod = MethodFinderUtils.findMethod(cls, MethodScope.OBJECT, MethodPrefixConstants.CLEAR_PREFIX + capitalizedName, void.class, NO_PARAMETERS_TYPES);
+
+ if (clearMethod == null) {
+ return null;
+ }
+ processMethodContext.removeMethod(clearMethod);
+
+ FacetUtil.addFacet(new PropertyClearFacetViaClearMethod(clearMethod, property));
+
+ return clearMethod;
+ }
+
+ private static void attachPropertyClearFacetUsingSetterIfRequired(final ProcessMethodContext processMethodContext, final Method setMethod, final Method clearMethod) {
+
+ if (clearMethod != null) {
+ return;
+ }
+ if (setMethod == null) {
+ return;
+ }
+ final FacetHolder property = processMethodContext.getFacetHolder();
+ FacetUtil.addFacet(new PropertyClearFacetViaSetterMethod(setMethod, property));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/update/clear/PropertyClearFacet.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/update/clear/PropertyClearFacet.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/update/clear/PropertyClearFacet.java
new file mode 100644
index 0000000..0b8fc87
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/update/clear/PropertyClearFacet.java
@@ -0,0 +1,38 @@
+/*
+ * 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.properties.update.clear;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.facetapi.Facet;
+
+/**
+ * Mechanism for clearing a property of an object (that is, setting it to
+ * <tt>null</tt>).
+ *
+ * <p>
+ * In the standard Apache Isis Programming Model, typically corresponds to a
+ * method named <tt>clearXxx</tt> (for a property <tt>getXxx</tt>). As a
+ * fallback the standard model also supports invoking the <tt>setXxx</tt> method
+ * with <tt>null</tt>.
+ */
+public interface PropertyClearFacet extends Facet {
+
+ public void clearProperty(ObjectAdapter inObject);
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/7227418b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/update/clear/PropertyClearFacetAbstract.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/update/clear/PropertyClearFacetAbstract.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/update/clear/PropertyClearFacetAbstract.java
new file mode 100644
index 0000000..13e25af
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/properties/update/clear/PropertyClearFacetAbstract.java
@@ -0,0 +1,35 @@
+/*
+ * 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.properties.update.clear;
+
+import org.apache.isis.core.metamodel.facetapi.Facet;
+import org.apache.isis.core.metamodel.facetapi.FacetAbstract;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+
+public abstract class PropertyClearFacetAbstract extends FacetAbstract implements PropertyClearFacet {
+
+ public static Class<? extends Facet> type() {
+ return PropertyClearFacet.class;
+ }
+
+ public PropertyClearFacetAbstract(final FacetHolder holder) {
+ super(type(), holder, Derivation.NOT_DERIVED);
+ }
+}