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 2015/02/06 19:12:56 UTC
[15/26] isis git commit: ISIS-1027: marking facet classes as
deprecated; some minor incidental tidy-up
http://git-wip-us.apache.org/repos/asf/isis/blob/34423fd5/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/regex/RegExFacet.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/regex/RegExFacet.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/regex/RegExFacet.java
deleted file mode 100644
index b22f3a8..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/regex/RegExFacet.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.object.regex;
-
-import org.apache.isis.core.metamodel.facets.MultipleValueFacet;
-import org.apache.isis.core.metamodel.interactions.ValidatingInteractionAdvisor;
-import org.apache.isis.core.metamodel.facets.object.mask.MaskFacet;
-
-/**
- * Whether the (string) property or a parameter must correspond to a specific
- * regular expression.
- *
- * <p>
- * In the standard Apache Isis Programming Model, corresponds to the
- * <tt>@RegEx</tt> annotation.
- *
- * @see MaskFacet
- */
-public interface RegExFacet extends MultipleValueFacet, ValidatingInteractionAdvisor {
-
- public String validation();
-
- public String format();
-
- public boolean caseSensitive();
-
- public boolean doesNotMatch(String proposed);
-
- public String format(String text);
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/34423fd5/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/regex/RegExFacetAbstract.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/regex/RegExFacetAbstract.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/regex/RegExFacetAbstract.java
deleted file mode 100644
index f344b7d..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/regex/RegExFacetAbstract.java
+++ /dev/null
@@ -1,81 +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.object.regex;
-
-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.MultipleValueFacetAbstract;
-import org.apache.isis.core.metamodel.interactions.ProposedHolder;
-import org.apache.isis.core.metamodel.interactions.ValidityContext;
-
-public abstract class RegExFacetAbstract extends MultipleValueFacetAbstract implements RegExFacet {
-
- public static Class<? extends Facet> type() {
- return RegExFacet.class;
- }
-
- private final String validation;
- private final String format;
- private final boolean caseSensitive;
-
- public RegExFacetAbstract(final String validation, final String format, final boolean caseSensitive, final FacetHolder holder) {
- super(type(), holder);
- this.validation = validation;
- this.format = format;
- this.caseSensitive = caseSensitive;
- }
-
- @Override
- public String validation() {
- return validation;
- }
-
- @Override
- public String format() {
- return format;
- }
-
- @Override
- public boolean caseSensitive() {
- return caseSensitive;
- }
-
- // //////////////////////////////////////////////////////////
-
- @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 (proposedArgument == null) {
- return null;
- }
- final String titleString = proposedArgument.titleString();
- if (!doesNotMatch(titleString)) {
- return null;
- }
- return "Doesn't match pattern";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/34423fd5/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/regex/TitleFacetFormattedByRegex.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/regex/TitleFacetFormattedByRegex.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/regex/TitleFacetFormattedByRegex.java
deleted file mode 100644
index 8c50a5e..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/regex/TitleFacetFormattedByRegex.java
+++ /dev/null
@@ -1,40 +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.object.regex;
-
-import org.apache.isis.applib.profiles.Localization;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.facets.object.title.TitleFacetAbstract;
-
-public class TitleFacetFormattedByRegex extends TitleFacetAbstract {
-
- private final RegExFacet regexFacet;
-
- public TitleFacetFormattedByRegex(final RegExFacet regexFacet) {
- super(regexFacet.getFacetHolder());
- this.regexFacet = regexFacet;
- }
-
- @Override
- public String title(final ObjectAdapter object, final Localization localization) {
- return regexFacet.format(object.titleString());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/34423fd5/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/regex/annotation/RegExFacetOnTypeAnnotation.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/regex/annotation/RegExFacetOnTypeAnnotation.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/regex/annotation/RegExFacetOnTypeAnnotation.java
index f00e9d7..00d2f53 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/regex/annotation/RegExFacetOnTypeAnnotation.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/regex/annotation/RegExFacetOnTypeAnnotation.java
@@ -22,8 +22,12 @@ package org.apache.isis.core.metamodel.facets.object.regex.annotation;
import java.util.regex.Pattern;
import org.apache.isis.core.metamodel.facetapi.FacetHolder;
-import org.apache.isis.core.metamodel.facets.object.regex.RegExFacetAbstract;
+import org.apache.isis.core.metamodel.facets.objectvalue.regex.RegExFacetAbstract;
+/**
+ * @deprecated
+ */
+@Deprecated
public class RegExFacetOnTypeAnnotation extends RegExFacetAbstract {
private final Pattern pattern;
http://git-wip-us.apache.org/repos/asf/isis/blob/34423fd5/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/regex/annotation/RegExFacetOnTypeAnnotationFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/regex/annotation/RegExFacetOnTypeAnnotationFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/regex/annotation/RegExFacetOnTypeAnnotationFactory.java
index 541efb5..ec992d7 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/regex/annotation/RegExFacetOnTypeAnnotationFactory.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/regex/annotation/RegExFacetOnTypeAnnotationFactory.java
@@ -27,10 +27,14 @@ import org.apache.isis.core.metamodel.facetapi.FeatureType;
import org.apache.isis.core.metamodel.facetapi.MetaModelValidatorRefiner;
import org.apache.isis.core.metamodel.facets.Annotations;
import org.apache.isis.core.metamodel.facets.FacetFactoryAbstract;
-import org.apache.isis.core.metamodel.facets.object.regex.RegExFacet;
+import org.apache.isis.core.metamodel.facets.objectvalue.regex.RegExFacet;
import org.apache.isis.core.metamodel.specloader.validator.MetaModelValidatorComposite;
import org.apache.isis.core.metamodel.specloader.validator.MetaModelValidatorForDeprecatedAnnotation;
+/**
+ * @deprecated
+ */
+@Deprecated
public class RegExFacetOnTypeAnnotationFactory extends FacetFactoryAbstract implements MetaModelValidatorRefiner, IsisConfigurationAware {
private final MetaModelValidatorForDeprecatedAnnotation validator = new MetaModelValidatorForDeprecatedAnnotation(RegEx.class);
http://git-wip-us.apache.org/repos/asf/isis/blob/34423fd5/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/typicallen/annotation/TypicalLengthFacetOnTypeAnnotation.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/typicallen/annotation/TypicalLengthFacetOnTypeAnnotation.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/typicallen/annotation/TypicalLengthFacetOnTypeAnnotation.java
index aa2348d..3ca469e 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/typicallen/annotation/TypicalLengthFacetOnTypeAnnotation.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/typicallen/annotation/TypicalLengthFacetOnTypeAnnotation.java
@@ -20,8 +20,12 @@
package org.apache.isis.core.metamodel.facets.object.typicallen.annotation;
import org.apache.isis.core.metamodel.facetapi.FacetHolder;
-import org.apache.isis.core.metamodel.facets.objpropparam.typicallen.TypicalLengthFacetAbstract;
+import org.apache.isis.core.metamodel.facets.objectvalue.typicallen.TypicalLengthFacetAbstract;
+/**
+ * @deprecated
+ */
+@Deprecated
public class TypicalLengthFacetOnTypeAnnotation extends TypicalLengthFacetAbstract {
private final int value;
http://git-wip-us.apache.org/repos/asf/isis/blob/34423fd5/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/typicallen/annotation/TypicalLengthFacetOnTypeAnnotationFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/typicallen/annotation/TypicalLengthFacetOnTypeAnnotationFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/typicallen/annotation/TypicalLengthFacetOnTypeAnnotationFactory.java
index 4771821..f6e71e9 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/typicallen/annotation/TypicalLengthFacetOnTypeAnnotationFactory.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/typicallen/annotation/TypicalLengthFacetOnTypeAnnotationFactory.java
@@ -27,10 +27,14 @@ import org.apache.isis.core.metamodel.facetapi.FeatureType;
import org.apache.isis.core.metamodel.facetapi.MetaModelValidatorRefiner;
import org.apache.isis.core.metamodel.facets.Annotations;
import org.apache.isis.core.metamodel.facets.FacetFactoryAbstract;
-import org.apache.isis.core.metamodel.facets.objpropparam.typicallen.TypicalLengthFacet;
+import org.apache.isis.core.metamodel.facets.objectvalue.typicallen.TypicalLengthFacet;
import org.apache.isis.core.metamodel.specloader.validator.MetaModelValidatorComposite;
import org.apache.isis.core.metamodel.specloader.validator.MetaModelValidatorForDeprecatedAnnotation;
+/**
+ * @deprecated
+ */
+@Deprecated
public class TypicalLengthFacetOnTypeAnnotationFactory extends FacetFactoryAbstract implements MetaModelValidatorRefiner, IsisConfigurationAware {
private final MetaModelValidatorForDeprecatedAnnotation validator = new MetaModelValidatorForDeprecatedAnnotation(TypicalLength.class);
http://git-wip-us.apache.org/repos/asf/isis/blob/34423fd5/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/validating/mustsatisfyspec/MustSatisfySpecificationFromMustSatisfyAnnotationOnTypeFacet.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/validating/mustsatisfyspec/MustSatisfySpecificationFromMustSatisfyAnnotationOnTypeFacet.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/validating/mustsatisfyspec/MustSatisfySpecificationFromMustSatisfyAnnotationOnTypeFacet.java
new file mode 100644
index 0000000..7efb6f8
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/validating/mustsatisfyspec/MustSatisfySpecificationFromMustSatisfyAnnotationOnTypeFacet.java
@@ -0,0 +1,67 @@
+/*
+ * 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.validating.mustsatisfyspec;
+
+import java.util.List;
+
+import org.apache.isis.applib.events.ValidityEvent;
+import org.apache.isis.applib.spec.Specification;
+import org.apache.isis.applib.util.ReasonBuffer;
+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.ProposedHolder;
+import org.apache.isis.core.metamodel.interactions.ValidatingInteractionAdvisor;
+import org.apache.isis.core.metamodel.interactions.ValidityContext;
+
+/**
+ * @deprecated
+ */
+@Deprecated
+public class MustSatisfySpecificationFromMustSatisfyAnnotationOnTypeFacet extends FacetAbstract implements ValidatingInteractionAdvisor {
+
+ public static Class<? extends Facet> type() {
+ return MustSatisfySpecificationFromMustSatisfyAnnotationOnTypeFacet.class;
+ }
+
+ private final List<Specification> specifications;
+
+ public MustSatisfySpecificationFromMustSatisfyAnnotationOnTypeFacet(final List<Specification> specifications, final FacetHolder holder) {
+ super(type(), holder, Derivation.NOT_DERIVED);
+ this.specifications = specifications;
+ }
+
+ @Override
+ public String invalidates(final ValidityContext<? extends ValidityEvent> validityContext) {
+ if (!(validityContext instanceof ProposedHolder)) {
+ return null;
+ }
+ final ProposedHolder proposedHolder = (ProposedHolder) validityContext;
+ final ObjectAdapter targetNO = proposedHolder.getProposed();
+ final Object targetObject = targetNO.getObject();
+ final ReasonBuffer buf = new ReasonBuffer();
+ for (final Specification specification : specifications) {
+ buf.append(specification.satisfies(targetObject));
+ }
+ return buf.getReason();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/34423fd5/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/validating/mustsatisfyspec/MustSatisfySpecificationFromMustSatisfyAnnotationOnTypeFacetFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/validating/mustsatisfyspec/MustSatisfySpecificationFromMustSatisfyAnnotationOnTypeFacetFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/validating/mustsatisfyspec/MustSatisfySpecificationFromMustSatisfyAnnotationOnTypeFacetFactory.java
new file mode 100644
index 0000000..14fda08
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/validating/mustsatisfyspec/MustSatisfySpecificationFromMustSatisfyAnnotationOnTypeFacetFactory.java
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.core.metamodel.facets.object.validating.mustsatisfyspec;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.isis.applib.annotation.MustSatisfy;
+import org.apache.isis.applib.spec.Specification;
+import org.apache.isis.core.commons.config.IsisConfiguration;
+import org.apache.isis.core.commons.config.IsisConfigurationAware;
+import org.apache.isis.core.metamodel.facetapi.Facet;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facetapi.FeatureType;
+import org.apache.isis.core.metamodel.facetapi.MetaModelValidatorRefiner;
+import org.apache.isis.core.metamodel.facets.Annotations;
+import org.apache.isis.core.metamodel.facets.FacetFactoryAbstract;
+import org.apache.isis.core.metamodel.specloader.validator.MetaModelValidatorComposite;
+import org.apache.isis.core.metamodel.specloader.validator.MetaModelValidatorForDeprecatedAnnotation;
+
+/**
+ * @deprecated
+ */
+@Deprecated
+public class MustSatisfySpecificationFromMustSatisfyAnnotationOnTypeFacetFactory extends FacetFactoryAbstract implements MetaModelValidatorRefiner, IsisConfigurationAware {
+
+ private final MetaModelValidatorForDeprecatedAnnotation validator = new MetaModelValidatorForDeprecatedAnnotation(MustSatisfy.class);
+
+ public MustSatisfySpecificationFromMustSatisfyAnnotationOnTypeFacetFactory() {
+ super(FeatureType.OBJECTS_ONLY);
+ }
+
+ @Override
+ public void process(final ProcessClassContext processClassContaxt) {
+ validator.addFacetFlagIfPresent(create(processClassContaxt.getCls(), processClassContaxt.getFacetHolder()));
+ }
+
+ private Facet create(final Class<?> clazz, final FacetHolder holder) {
+ return create(Annotations.getAnnotation(clazz, MustSatisfy.class), holder);
+ }
+
+ private static Facet create(final MustSatisfy annotation, final FacetHolder holder) {
+ if (annotation == null) {
+ return null;
+ }
+ final Class<?>[] values = annotation.value();
+ final List<Specification> specifications = new ArrayList<Specification>();
+ for (final Class<?> value : values) {
+ final Specification specification = newSpecificationElseNull(value);
+ if (specification != null) {
+ specifications.add(specification);
+ }
+ }
+ return specifications.size() > 0 ? new MustSatisfySpecificationFromMustSatisfyAnnotationOnTypeFacet(specifications, holder) : null;
+ }
+
+ private static Specification newSpecificationElseNull(final Class<?> value) {
+ if (!(Specification.class.isAssignableFrom(value))) {
+ return null;
+ }
+ try {
+ return (Specification) value.newInstance();
+ } catch (final InstantiationException e) {
+ return null;
+ } catch (final IllegalAccessException e) {
+ return null;
+ }
+ }
+
+ @Override
+ public void refineMetaModelValidator(final MetaModelValidatorComposite metaModelValidator, final IsisConfiguration configuration) {
+ metaModelValidator.add(validator);
+ }
+
+ @Override
+ public void setConfiguration(final IsisConfiguration configuration) {
+ validator.setConfiguration(configuration);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/34423fd5/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/validating/mustsatisfyspec/MustSatisfySpecificationOnTypeFacet.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/validating/mustsatisfyspec/MustSatisfySpecificationOnTypeFacet.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/validating/mustsatisfyspec/MustSatisfySpecificationOnTypeFacet.java
deleted file mode 100644
index 6a8bb32..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/validating/mustsatisfyspec/MustSatisfySpecificationOnTypeFacet.java
+++ /dev/null
@@ -1,63 +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.object.validating.mustsatisfyspec;
-
-import java.util.List;
-
-import org.apache.isis.applib.events.ValidityEvent;
-import org.apache.isis.applib.spec.Specification;
-import org.apache.isis.applib.util.ReasonBuffer;
-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.ProposedHolder;
-import org.apache.isis.core.metamodel.interactions.ValidatingInteractionAdvisor;
-import org.apache.isis.core.metamodel.interactions.ValidityContext;
-
-public class MustSatisfySpecificationOnTypeFacet extends FacetAbstract implements ValidatingInteractionAdvisor {
-
- public static Class<? extends Facet> type() {
- return MustSatisfySpecificationOnTypeFacet.class;
- }
-
- private final List<Specification> specifications;
-
- public MustSatisfySpecificationOnTypeFacet(final List<Specification> specifications, final FacetHolder holder) {
- super(type(), holder, Derivation.NOT_DERIVED);
- this.specifications = specifications;
- }
-
- @Override
- public String invalidates(final ValidityContext<? extends ValidityEvent> validityContext) {
- if (!(validityContext instanceof ProposedHolder)) {
- return null;
- }
- final ProposedHolder proposedHolder = (ProposedHolder) validityContext;
- final ObjectAdapter targetNO = proposedHolder.getProposed();
- final Object targetObject = targetNO.getObject();
- final ReasonBuffer buf = new ReasonBuffer();
- for (final Specification specification : specifications) {
- buf.append(specification.satisfies(targetObject));
- }
- return buf.getReason();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/34423fd5/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/validating/mustsatisfyspec/MustSatisfySpecificationOnTypeFacetFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/validating/mustsatisfyspec/MustSatisfySpecificationOnTypeFacetFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/validating/mustsatisfyspec/MustSatisfySpecificationOnTypeFacetFactory.java
deleted file mode 100644
index b84f730..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/validating/mustsatisfyspec/MustSatisfySpecificationOnTypeFacetFactory.java
+++ /dev/null
@@ -1,92 +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.object.validating.mustsatisfyspec;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.isis.applib.annotation.MustSatisfy;
-import org.apache.isis.applib.spec.Specification;
-import org.apache.isis.core.commons.config.IsisConfiguration;
-import org.apache.isis.core.commons.config.IsisConfigurationAware;
-import org.apache.isis.core.metamodel.facetapi.Facet;
-import org.apache.isis.core.metamodel.facetapi.FacetHolder;
-import org.apache.isis.core.metamodel.facetapi.FeatureType;
-import org.apache.isis.core.metamodel.facetapi.MetaModelValidatorRefiner;
-import org.apache.isis.core.metamodel.facets.Annotations;
-import org.apache.isis.core.metamodel.facets.FacetFactoryAbstract;
-import org.apache.isis.core.metamodel.specloader.validator.MetaModelValidatorComposite;
-import org.apache.isis.core.metamodel.specloader.validator.MetaModelValidatorForDeprecatedAnnotation;
-
-public class MustSatisfySpecificationOnTypeFacetFactory extends FacetFactoryAbstract implements MetaModelValidatorRefiner, IsisConfigurationAware {
-
- private final MetaModelValidatorForDeprecatedAnnotation validator = new MetaModelValidatorForDeprecatedAnnotation(MustSatisfy.class);
-
- public MustSatisfySpecificationOnTypeFacetFactory() {
- super(FeatureType.OBJECTS_ONLY);
- }
-
- @Override
- public void process(final ProcessClassContext processClassContaxt) {
- validator.addFacetFlagIfPresent(create(processClassContaxt.getCls(), processClassContaxt.getFacetHolder()));
- }
-
- private Facet create(final Class<?> clazz, final FacetHolder holder) {
- return create(Annotations.getAnnotation(clazz, MustSatisfy.class), holder);
- }
-
- private static Facet create(final MustSatisfy annotation, final FacetHolder holder) {
- if (annotation == null) {
- return null;
- }
- final Class<?>[] values = annotation.value();
- final List<Specification> specifications = new ArrayList<Specification>();
- for (final Class<?> value : values) {
- final Specification specification = newSpecificationElseNull(value);
- if (specification != null) {
- specifications.add(specification);
- }
- }
- return specifications.size() > 0 ? new MustSatisfySpecificationOnTypeFacet(specifications, holder) : null;
- }
-
- private static Specification newSpecificationElseNull(final Class<?> value) {
- if (!(Specification.class.isAssignableFrom(value))) {
- return null;
- }
- try {
- return (Specification) value.newInstance();
- } catch (final InstantiationException e) {
- return null;
- } catch (final IllegalAccessException e) {
- return null;
- }
- }
-
- @Override
- public void refineMetaModelValidator(final MetaModelValidatorComposite metaModelValidator, final IsisConfiguration configuration) {
- metaModelValidator.add(validator);
- }
-
- @Override
- public void setConfiguration(final IsisConfiguration configuration) {
- validator.setConfiguration(configuration);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/34423fd5/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/value/MaxLengthFacetUsingParser2.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/value/MaxLengthFacetUsingParser2.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/value/MaxLengthFacetUsingParser2.java
index 223b054..78194ba 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/value/MaxLengthFacetUsingParser2.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/value/MaxLengthFacetUsingParser2.java
@@ -21,7 +21,7 @@ package org.apache.isis.core.metamodel.facets.object.value;
import org.apache.isis.applib.adapters.Parser2;
import org.apache.isis.core.metamodel.facetapi.FacetHolder;
-import org.apache.isis.core.metamodel.facets.propparam.maxlen.MaxLengthFacetAbstract;
+import org.apache.isis.core.metamodel.facets.objectvalue.maxlen.MaxLengthFacetAbstract;
import org.apache.isis.core.metamodel.runtimecontext.ServicesInjector;
public class MaxLengthFacetUsingParser2 extends MaxLengthFacetAbstract{
http://git-wip-us.apache.org/repos/asf/isis/blob/34423fd5/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/value/TypicalLengthFacetUsingParser.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/value/TypicalLengthFacetUsingParser.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/value/TypicalLengthFacetUsingParser.java
index 101ddd1..9190863 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/value/TypicalLengthFacetUsingParser.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/value/TypicalLengthFacetUsingParser.java
@@ -22,7 +22,7 @@ package org.apache.isis.core.metamodel.facets.object.value;
import org.apache.isis.applib.adapters.Parser;
import org.apache.isis.core.metamodel.facetapi.FacetAbstract;
import org.apache.isis.core.metamodel.facetapi.FacetHolder;
-import org.apache.isis.core.metamodel.facets.objpropparam.typicallen.TypicalLengthFacet;
+import org.apache.isis.core.metamodel.facets.objectvalue.typicallen.TypicalLengthFacet;
import org.apache.isis.core.metamodel.runtimecontext.ServicesInjector;
public class TypicalLengthFacetUsingParser extends FacetAbstract implements TypicalLengthFacet {
http://git-wip-us.apache.org/repos/asf/isis/blob/34423fd5/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/choices/ChoicesFacet.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/choices/ChoicesFacet.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/choices/ChoicesFacet.java
new file mode 100644
index 0000000..0f99262
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/choices/ChoicesFacet.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.objectvalue.choices;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.facetapi.Facet;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+
+public interface ChoicesFacet extends Facet {
+
+ /**
+ * Gets a set of choices for this object.
+ */
+ public Object[] getChoices(ObjectAdapter adapter);
+
+
+
+ public static class Util {
+
+ private Util() {
+ }
+
+ public static boolean hasChoices(final ObjectSpecification specification) {
+ return specification.getFacet(ChoicesFacet.class) != null;
+ }
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/34423fd5/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/choices/ChoicesFacetAbstract.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/choices/ChoicesFacetAbstract.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/choices/ChoicesFacetAbstract.java
new file mode 100644
index 0000000..74eb0ae
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/choices/ChoicesFacetAbstract.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.core.metamodel.facets.objectvalue.choices;
+
+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 ChoicesFacetAbstract extends FacetAbstract implements ChoicesFacet {
+
+ public static Class<? extends Facet> type() {
+ return ChoicesFacet.class;
+ }
+
+ public ChoicesFacetAbstract(final FacetHolder holder) {
+ super(type(), holder, Derivation.NOT_DERIVED);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/34423fd5/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/labelat/LabelAtFacet.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/labelat/LabelAtFacet.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/labelat/LabelAtFacet.java
new file mode 100644
index 0000000..9cea0d4
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/labelat/LabelAtFacet.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.core.metamodel.facets.objectvalue.labelat;
+
+import org.apache.isis.applib.annotation.LabelPosition;
+import org.apache.isis.core.metamodel.facetapi.Facet;
+
+/**
+ * Corresponds to either {@literal @}{@link org.apache.isis.applib.annotation.PropertyLayout#labelPosition()} (for a property) or
+ *{@literal @}{@link org.apache.isis.applib.annotation.ParameterLayout#labelPosition()} (for an action parameter).
+ */
+public interface LabelAtFacet extends Facet {
+
+ /**
+ * The positioning of a property or action parameter's label.
+ */
+ public LabelPosition label();
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/34423fd5/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/labelat/LabelAtFacetAbstract.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/labelat/LabelAtFacetAbstract.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/labelat/LabelAtFacetAbstract.java
new file mode 100644
index 0000000..c0fb69f
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/labelat/LabelAtFacetAbstract.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.objectvalue.labelat;
+
+import org.apache.isis.applib.annotation.LabelPosition;
+import org.apache.isis.core.metamodel.facetapi.Facet;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.MultipleValueFacetAbstract;
+
+public abstract class LabelAtFacetAbstract extends MultipleValueFacetAbstract implements LabelAtFacet {
+
+ public static Class<? extends Facet> type() {
+ return LabelAtFacet.class;
+ }
+
+ private final LabelPosition value;
+
+ public LabelAtFacetAbstract(final LabelPosition value, final FacetHolder holder) {
+ super(type(), holder);
+ this.value = value;
+ }
+
+ @Override
+ public LabelPosition label() {
+ return value;
+ }
+
+ @Override
+ protected String toStringValues() {
+ return "position=" + value;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/34423fd5/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/labelat/LabelAtFacetInferredFromMultiLineFacet.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/labelat/LabelAtFacetInferredFromMultiLineFacet.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/labelat/LabelAtFacetInferredFromMultiLineFacet.java
new file mode 100644
index 0000000..c14fd71
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/labelat/LabelAtFacetInferredFromMultiLineFacet.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.objectvalue.labelat;
+
+import org.apache.isis.applib.annotation.LabelPosition;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+
+/**
+ * If multi-line then position the label at the top.
+ *
+ * <p>
+ * This can still be overridden using the {@link org.apache.isis.applib.annotation.PropertyLayout} annotation / layout.json.
+ * </p>
+ */
+public class LabelAtFacetInferredFromMultiLineFacet extends LabelAtFacetAbstract {
+
+ public LabelAtFacetInferredFromMultiLineFacet(final FacetHolder holder) {
+ super(LabelPosition.TOP, holder);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/34423fd5/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/mandatory/MandatoryFacet.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/mandatory/MandatoryFacet.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/mandatory/MandatoryFacet.java
new file mode 100644
index 0000000..ea32a84
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/mandatory/MandatoryFacet.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.core.metamodel.facets.objectvalue.mandatory;
+
+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.MarkerFacet;
+import org.apache.isis.core.metamodel.interactions.ValidatingInteractionAdvisor;
+
+/**
+ * Whether a property or a parameter is mandatory (not optional).
+ *
+ * <p>
+ * For a mandatory property, the object cannot be saved/updated without the
+ * value being provided. For a mandatory parameter, the action cannot be invoked
+ * without the value being provided.
+ *
+ * <p>
+ * In the standard Apache Isis Programming Model, specify mandatory by
+ * <i>omitting</i> the <tt>@Optional</tt> annotation.
+ */
+public interface MandatoryFacet extends MarkerFacet, ValidatingInteractionAdvisor {
+
+ /**
+ * Whether this value is required but has not been provided (and is
+ * therefore invalid).
+ *
+ * <p>
+ * If the value has been provided, <i>or</i> if the property or parameter is
+ * not required, then will return <tt>false</tt>.
+ */
+ boolean isRequiredButNull(ObjectAdapter adapter);
+
+ /**
+ * Indicates that the implementation is overridding the usual semantics, in
+ * other words that the {@link FacetHolder} to which this {@link Facet} is
+ * attached is <i>not</i> mandatory.
+ */
+ public boolean isInvertedSemantics();
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/34423fd5/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/mandatory/MandatoryFacetAbstract.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/mandatory/MandatoryFacetAbstract.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/mandatory/MandatoryFacetAbstract.java
new file mode 100644
index 0000000..85e572b
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/mandatory/MandatoryFacetAbstract.java
@@ -0,0 +1,97 @@
+/*
+ * 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.objectvalue.mandatory;
+
+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.MarkerFacetAbstract;
+import org.apache.isis.core.metamodel.facets.all.named.NamedFacet;
+import org.apache.isis.core.metamodel.interactions.ActionArgumentContext;
+import org.apache.isis.core.metamodel.interactions.PropertyModifyContext;
+import org.apache.isis.core.metamodel.interactions.ProposedHolder;
+import org.apache.isis.core.metamodel.interactions.ValidityContext;
+
+public abstract class MandatoryFacetAbstract extends MarkerFacetAbstract implements MandatoryFacet {
+
+ public static Class<? extends Facet> type() {
+ return MandatoryFacet.class;
+ }
+
+ public enum Semantics {
+ REQUIRED,
+ OPTIONAL;
+
+ public static Semantics of(boolean required) {
+ return required ? REQUIRED: OPTIONAL;
+ }
+ }
+
+ private Semantics semantics;
+
+ public MandatoryFacetAbstract(final FacetHolder holder, final Semantics semantics) {
+ super(type(), holder);
+ this.semantics = semantics;
+ }
+
+ /**
+ * If not specified or, if a string, then zero length.
+ */
+ @Override
+ public final boolean isRequiredButNull(final ObjectAdapter adapter) {
+ if(!isInvertedSemantics()) {
+ final Object object = ObjectAdapter.Util.unwrap(adapter);
+ if (object == null) {
+ return true;
+ }
+ // special case string handling.
+ final String str = ObjectAdapter.Util.unwrapAsString(adapter);
+ return str != null && str.length() == 0;
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public boolean isInvertedSemantics() {
+ return this.semantics == Semantics.OPTIONAL;
+ }
+
+ @Override
+ public String invalidates(final ValidityContext<? extends ValidityEvent> context) {
+ if (!(context instanceof PropertyModifyContext) && !(context instanceof ActionArgumentContext)) {
+ return null;
+ }
+ if (!(context instanceof ProposedHolder)) {
+ // shouldn't happen, since both the above should hold a proposed
+ // value/argument
+ return null;
+ }
+ final ProposedHolder proposedHolder = (ProposedHolder) context;
+ final boolean required = isRequiredButNull(proposedHolder.getProposed());
+ if (!required) {
+ return null;
+ }
+ final NamedFacet namedFacet = getFacetHolder().getFacet(NamedFacet.class);
+ final String name = namedFacet != null? namedFacet.value(): null;
+ return name != null? "'" + name + "' is mandatory":"Mandatory";
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/34423fd5/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/mandatory/MandatoryFacetDefault.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/mandatory/MandatoryFacetDefault.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/mandatory/MandatoryFacetDefault.java
new file mode 100644
index 0000000..7546869
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/mandatory/MandatoryFacetDefault.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.objectvalue.mandatory;
+
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+
+/**
+ * Whether a property or a parameter is mandatory (not optional).
+ *
+ * <p>
+ * For a mandatory property, the object cannot be saved/updated without the
+ * value being provided. For a mandatory parameter, the action cannot be invoked
+ * without the value being provided.
+ *
+ * <p>
+ * In the standard Apache Isis Programming Model, specify mandatory by
+ * <i>omitting</i> the <tt>@Optional</tt> annotation.
+ */
+public class MandatoryFacetDefault extends MandatoryFacetAbstract {
+
+ public MandatoryFacetDefault(final FacetHolder holder) {
+ super(holder, Semantics.REQUIRED);
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/34423fd5/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/maxlen/MaxLengthFacet.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/maxlen/MaxLengthFacet.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/maxlen/MaxLengthFacet.java
new file mode 100644
index 0000000..35fc3e6
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/maxlen/MaxLengthFacet.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.objectvalue.maxlen;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.facets.SingleIntValueFacet;
+import org.apache.isis.core.metamodel.interactions.ValidatingInteractionAdvisor;
+
+/**
+ * Whether the (string) property or a parameter's length must not exceed a
+ * certain length.
+ *
+ * <p>
+ * In the standard Apache Isis Programming Model, corresponds to the
+ * <tt>@MaxLength</tt> annotation.
+ */
+public interface MaxLengthFacet extends SingleIntValueFacet, ValidatingInteractionAdvisor {
+
+ /**
+ * Whether the provided string exceeds the maximum length.
+ */
+ public boolean exceeds(ObjectAdapter adapter);
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/34423fd5/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/maxlen/MaxLengthFacetAbstract.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/maxlen/MaxLengthFacetAbstract.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/maxlen/MaxLengthFacetAbstract.java
new file mode 100644
index 0000000..871f053
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/maxlen/MaxLengthFacetAbstract.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.objectvalue.maxlen;
+
+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.SingleIntValueFacetAbstract;
+import org.apache.isis.core.metamodel.interactions.ProposedHolder;
+import org.apache.isis.core.metamodel.interactions.ValidityContext;
+import org.apache.isis.core.metamodel.spec.ObjectAdapterUtils;
+
+public abstract class MaxLengthFacetAbstract extends SingleIntValueFacetAbstract implements MaxLengthFacet {
+
+ public static Class<? extends Facet> type() {
+ return MaxLengthFacet.class;
+ }
+
+ public MaxLengthFacetAbstract(final int value, final FacetHolder holder) {
+ super(type(), holder, value);
+ }
+
+ /**
+ * Whether the provided argument exceeds the {@link #value() maximum length}
+ * .
+ */
+ @Override
+ public boolean exceeds(final ObjectAdapter adapter) {
+ final String str = ObjectAdapterUtils.unwrapObjectAsString(adapter);
+ if (str == null) {
+ return false;
+ }
+ final int maxLength = value();
+ return maxLength != 0 && str.length() > maxLength;
+ }
+
+ @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 (!exceeds(proposedArgument)) {
+ return null;
+ }
+ return "The value proposed exceeds the maximum length of " + value();
+ }
+
+ @Override
+ protected String toStringValues() {
+ final int val = value();
+ return val == 0 ? "unlimited" : String.valueOf(val);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/34423fd5/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/multiline/MultiLineFacet.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/multiline/MultiLineFacet.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/multiline/MultiLineFacet.java
new file mode 100644
index 0000000..2678ed5
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/multiline/MultiLineFacet.java
@@ -0,0 +1,51 @@
+/*
+ * 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.objectvalue.multiline;
+
+import org.apache.isis.core.metamodel.facets.MultipleValueFacet;
+
+/**
+ * Whether the (string) property or parameter should be rendered over multiple
+ * lines.
+ *
+ * <p>
+ * In the standard Apache Isis Programming Model, corresponds to the
+ * <tt>@MultiLine</tt> annotation.
+ */
+public interface MultiLineFacet extends MultipleValueFacet {
+
+ /**
+ * How many lines to use.
+ */
+ public int numberOfLines();
+
+ /**
+ * Whether carriage returns should be used to split over multiple lines or
+ * not.
+ *
+ * <p>
+ * If set to <tt>true</tt>, then user must use carriage returns to split. If
+ * set to <tt>false</tt>, then the viewer should automatically wrap when
+ * spills over the length of one line.
+ */
+ @Deprecated
+ public boolean preventWrapping();
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/34423fd5/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/multiline/MultiLineFacetAbstract.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/multiline/MultiLineFacetAbstract.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/multiline/MultiLineFacetAbstract.java
new file mode 100644
index 0000000..698038b
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/multiline/MultiLineFacetAbstract.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.objectvalue.multiline;
+
+import org.apache.isis.core.metamodel.facetapi.Facet;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.MultipleValueFacetAbstract;
+
+public abstract class MultiLineFacetAbstract extends MultipleValueFacetAbstract implements MultiLineFacet {
+
+ public static Class<? extends Facet> type() {
+ return MultiLineFacet.class;
+ }
+
+ private final int numberOfLines;
+ private final boolean preventWrapping;
+
+ public MultiLineFacetAbstract(final int numberOfLines, final boolean preventWrapping, final FacetHolder holder) {
+ super(type(), holder);
+ this.numberOfLines = numberOfLines;
+ this.preventWrapping = preventWrapping;
+ }
+
+ @Override
+ public int numberOfLines() {
+ return numberOfLines;
+ }
+
+ @Override
+ public boolean preventWrapping() {
+ return preventWrapping;
+ }
+
+ @Override
+ protected String toStringValues() {
+ return "lines=" + numberOfLines + "," + (preventWrapping ? "prevent-wrapping" : "allow-wrapping");
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/34423fd5/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/mustsatisfyspec/MustSatisfySpecificationFacet.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/mustsatisfyspec/MustSatisfySpecificationFacet.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/mustsatisfyspec/MustSatisfySpecificationFacet.java
new file mode 100644
index 0000000..06e931a
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/mustsatisfyspec/MustSatisfySpecificationFacet.java
@@ -0,0 +1,27 @@
+/*
+ * 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.objectvalue.mustsatisfyspec;
+
+import org.apache.isis.core.metamodel.facetapi.Facet;
+import org.apache.isis.core.metamodel.interactions.ValidatingInteractionAdvisor;
+
+public interface MustSatisfySpecificationFacet extends Facet, ValidatingInteractionAdvisor {
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/34423fd5/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/mustsatisfyspec/MustSatisfySpecificationFacetAbstract.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/mustsatisfyspec/MustSatisfySpecificationFacetAbstract.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/mustsatisfyspec/MustSatisfySpecificationFacetAbstract.java
new file mode 100644
index 0000000..7e22b51
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/mustsatisfyspec/MustSatisfySpecificationFacetAbstract.java
@@ -0,0 +1,87 @@
+/*
+ * 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.objectvalue.mustsatisfyspec;
+
+import java.util.List;
+import org.apache.isis.applib.events.ValidityEvent;
+import org.apache.isis.applib.spec.Specification;
+import org.apache.isis.applib.util.ReasonBuffer;
+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.ProposedHolder;
+import org.apache.isis.core.metamodel.interactions.ValidityContext;
+
+public abstract class MustSatisfySpecificationFacetAbstract extends FacetAbstract implements MustSatisfySpecificationFacet {
+
+ public static Class<? extends Facet> type() {
+ return MustSatisfySpecificationFacet.class;
+ }
+
+ private final List<Specification> specifications;
+
+ /**
+ * For testing.
+ */
+ public List<Specification> getSpecifications() {
+ return specifications;
+ }
+
+ public MustSatisfySpecificationFacetAbstract(final List<Specification> specifications, final FacetHolder holder) {
+ super(type(), holder, Derivation.NOT_DERIVED);
+ this.specifications = specifications;
+ }
+
+ @Override
+ public String invalidates(final ValidityContext<? extends ValidityEvent> validityContext) {
+ if (!(validityContext instanceof ProposedHolder)) {
+ return null;
+ }
+ final ProposedHolder proposedHolder = (ProposedHolder) validityContext;
+ final ObjectAdapter proposedAdapter = proposedHolder.getProposed();
+ if(proposedAdapter == null) {
+ return null;
+ }
+ final Object proposedObject = proposedAdapter.getObject();
+ final ReasonBuffer buf = new ReasonBuffer();
+ for (final Specification specification : specifications) {
+ buf.append(specification.satisfies(proposedObject));
+ }
+ return buf.getReason();
+ }
+
+ /**
+ * For benefit of subclasses.
+ */
+ protected static Specification newSpecificationElseNull(final Class<?> value) {
+ if (!(Specification.class.isAssignableFrom(value))) {
+ return null;
+ }
+ try {
+ return (Specification) value.newInstance();
+ } catch (final InstantiationException e) {
+ return null;
+ } catch (final IllegalAccessException e) {
+ return null;
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/34423fd5/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/regex/RegExFacet.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/regex/RegExFacet.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/regex/RegExFacet.java
new file mode 100644
index 0000000..c48af00
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/regex/RegExFacet.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.objectvalue.regex;
+
+import org.apache.isis.core.metamodel.facets.MultipleValueFacet;
+import org.apache.isis.core.metamodel.interactions.ValidatingInteractionAdvisor;
+import org.apache.isis.core.metamodel.facets.object.mask.MaskFacet;
+
+/**
+ * Whether the (string) property or a parameter must correspond to a specific
+ * regular expression.
+ *
+ * <p>
+ * In the standard Apache Isis Programming Model, corresponds to the
+ * <tt>@RegEx</tt> annotation.
+ *
+ * @see MaskFacet
+ */
+public interface RegExFacet extends MultipleValueFacet, ValidatingInteractionAdvisor {
+
+ public String validation();
+
+ public String format();
+
+ public boolean caseSensitive();
+
+ public boolean doesNotMatch(String proposed);
+
+ public String format(String text);
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/34423fd5/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/regex/RegExFacetAbstract.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/regex/RegExFacetAbstract.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/regex/RegExFacetAbstract.java
new file mode 100644
index 0000000..7e46ff2
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/regex/RegExFacetAbstract.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.objectvalue.regex;
+
+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.MultipleValueFacetAbstract;
+import org.apache.isis.core.metamodel.interactions.ProposedHolder;
+import org.apache.isis.core.metamodel.interactions.ValidityContext;
+
+public abstract class RegExFacetAbstract extends MultipleValueFacetAbstract implements RegExFacet {
+
+ public static Class<? extends Facet> type() {
+ return RegExFacet.class;
+ }
+
+ private final String validation;
+ private final String format;
+ private final boolean caseSensitive;
+
+ public RegExFacetAbstract(final String validation, final String format, final boolean caseSensitive, final FacetHolder holder) {
+ super(type(), holder);
+ this.validation = validation;
+ this.format = format;
+ this.caseSensitive = caseSensitive;
+ }
+
+ @Override
+ public String validation() {
+ return validation;
+ }
+
+ @Override
+ public String format() {
+ return format;
+ }
+
+ @Override
+ public boolean caseSensitive() {
+ return caseSensitive;
+ }
+
+ // //////////////////////////////////////////////////////////
+
+ @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 (proposedArgument == null) {
+ return null;
+ }
+ final String titleString = proposedArgument.titleString();
+ if (!doesNotMatch(titleString)) {
+ return null;
+ }
+ return "Doesn't match pattern";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/34423fd5/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/regex/TitleFacetFormattedByRegex.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/regex/TitleFacetFormattedByRegex.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/regex/TitleFacetFormattedByRegex.java
new file mode 100644
index 0000000..6726611
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/regex/TitleFacetFormattedByRegex.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.objectvalue.regex;
+
+import org.apache.isis.applib.profiles.Localization;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.facets.object.title.TitleFacetAbstract;
+
+public class TitleFacetFormattedByRegex extends TitleFacetAbstract {
+
+ private final RegExFacet regexFacet;
+
+ public TitleFacetFormattedByRegex(final RegExFacet regexFacet) {
+ super(regexFacet.getFacetHolder());
+ this.regexFacet = regexFacet;
+ }
+
+ @Override
+ public String title(final ObjectAdapter object, final Localization localization) {
+ return regexFacet.format(object.titleString());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/34423fd5/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/renderedadjusted/RenderedAdjustedFacet.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/renderedadjusted/RenderedAdjustedFacet.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/renderedadjusted/RenderedAdjustedFacet.java
new file mode 100644
index 0000000..35a85dd
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/renderedadjusted/RenderedAdjustedFacet.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.objectvalue.renderedadjusted;
+
+import org.apache.isis.core.metamodel.facets.SingleIntValueFacet;
+
+/**
+ * The amount to adjust a date by when rendered.
+ *
+ * <p>
+ * Intended to be used by the viewer as a rendering hint.
+ *
+ * <p>
+ * In the standard Apache Isis Programming Model, corresponds to the
+ * <tt>@RenderedAdjusted</tt> annotation.
+ */
+public interface RenderedAdjustedFacet extends SingleIntValueFacet {
+
+ @Override
+ public int value();
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/34423fd5/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/renderedadjusted/RenderedAdjustedFacetAbstract.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/renderedadjusted/RenderedAdjustedFacetAbstract.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/renderedadjusted/RenderedAdjustedFacetAbstract.java
new file mode 100644
index 0000000..43864fc
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/renderedadjusted/RenderedAdjustedFacetAbstract.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.objectvalue.renderedadjusted;
+
+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 RenderedAdjustedFacetAbstract extends FacetAbstract implements RenderedAdjustedFacet {
+
+ public static Class<? extends Facet> type() {
+ return RenderedAdjustedFacet.class;
+ }
+
+ private final int adjustBy;
+
+ public RenderedAdjustedFacetAbstract(int adjustBy, final FacetHolder holder) {
+ super(type(), holder, Derivation.NOT_DERIVED);
+ this.adjustBy = adjustBy;
+ }
+
+ @Override
+ public int value() {
+ return adjustBy;
+ }
+
+ @Override
+ protected String toStringValues() {
+ final int val = value();
+ return val == -1 ? "default" : String.valueOf(val);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/34423fd5/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/typicallen/TypicalLengthFacet.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/typicallen/TypicalLengthFacet.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/typicallen/TypicalLengthFacet.java
new file mode 100644
index 0000000..ab2ad1f
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/typicallen/TypicalLengthFacet.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.objectvalue.typicallen;
+
+import org.apache.isis.core.metamodel.facets.SingleIntValueFacet;
+
+/**
+ * The typical length of a property or a parameter.
+ *
+ * <p>
+ * Intended to be used by the viewer as a rendering hint to size the UI field to
+ * an appropriate size.
+ *
+ * <p>
+ * In the standard Apache Isis Programming Model, corresponds to the
+ * <tt>@TypicalLength</tt> annotation.
+ */
+public interface TypicalLengthFacet extends SingleIntValueFacet {
+
+ @Override
+ public int value();
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/34423fd5/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/typicallen/TypicalLengthFacetAbstract.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/typicallen/TypicalLengthFacetAbstract.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/typicallen/TypicalLengthFacetAbstract.java
new file mode 100644
index 0000000..b2acdf1
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/objectvalue/typicallen/TypicalLengthFacetAbstract.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.objectvalue.typicallen;
+
+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 TypicalLengthFacetAbstract extends FacetAbstract implements TypicalLengthFacet {
+
+ public static Class<? extends Facet> type() {
+ return TypicalLengthFacet.class;
+ }
+
+ public TypicalLengthFacetAbstract(final FacetHolder holder, final Derivation derivation) {
+ super(type(), holder, derivation);
+ }
+
+ @Override
+ public abstract int value();
+
+ @Override
+ protected String toStringValues() {
+ final int val = value();
+ return val == 0 ? "default" : String.valueOf(val);
+ }
+
+}