http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/zest/api/constraint/Constraint.java ---------------------------------------------------------------------- diff --git a/core/api/src/main/java/org/apache/zest/api/constraint/Constraint.java b/core/api/src/main/java/org/apache/zest/api/constraint/Constraint.java deleted file mode 100644 index c426e8d..0000000 --- a/core/api/src/main/java/org/apache/zest/api/constraint/Constraint.java +++ /dev/null @@ -1,45 +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.zest.api.constraint; - -import java.io.Serializable; -import java.lang.annotation.Annotation; - -/** - * All Constraints must implement this interface, which is used for each - * value validation. - */ -public interface Constraint<ANNOTATION extends Annotation, TYPE> - extends Serializable -{ - /** - * For each value or parameter which should be checked this method will be invoked. - * If the method returns true the value is valid. If it returns false the value - * is considered invalid. When all constraints have been checked a ConstraintViolationException - * will be thrown with all the constraint violations that were found. - * - * @param annotation the annotation to match - * @param value the value to be checked - * - * @return true if valid, false if invalid - */ - boolean isValid( ANNOTATION annotation, TYPE value ); -}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/zest/api/constraint/ConstraintDeclaration.java ---------------------------------------------------------------------- diff --git a/core/api/src/main/java/org/apache/zest/api/constraint/ConstraintDeclaration.java b/core/api/src/main/java/org/apache/zest/api/constraint/ConstraintDeclaration.java deleted file mode 100644 index 85e7072..0000000 --- a/core/api/src/main/java/org/apache/zest/api/constraint/ConstraintDeclaration.java +++ /dev/null @@ -1,37 +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.zest.api.constraint; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * All annotations that are used to trigger Constraints must have this annotation. - */ -@Retention( RetentionPolicy.RUNTIME ) -@Target( ElementType.ANNOTATION_TYPE ) -@Documented -public @interface ConstraintDeclaration -{ -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/zest/api/constraint/ConstraintDescriptor.java ---------------------------------------------------------------------- diff --git a/core/api/src/main/java/org/apache/zest/api/constraint/ConstraintDescriptor.java b/core/api/src/main/java/org/apache/zest/api/constraint/ConstraintDescriptor.java deleted file mode 100644 index 9272e38..0000000 --- a/core/api/src/main/java/org/apache/zest/api/constraint/ConstraintDescriptor.java +++ /dev/null @@ -1,31 +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.zest.api.constraint; - -import java.lang.annotation.Annotation; - -/** - * Constraint Descriptor. - */ -public interface ConstraintDescriptor -{ - Annotation annotation(); -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/zest/api/constraint/ConstraintImplementationNotFoundException.java ---------------------------------------------------------------------- diff --git a/core/api/src/main/java/org/apache/zest/api/constraint/ConstraintImplementationNotFoundException.java b/core/api/src/main/java/org/apache/zest/api/constraint/ConstraintImplementationNotFoundException.java deleted file mode 100644 index 13312ec..0000000 --- a/core/api/src/main/java/org/apache/zest/api/constraint/ConstraintImplementationNotFoundException.java +++ /dev/null @@ -1,34 +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.zest.api.constraint; - -import org.apache.zest.api.common.InvalidApplicationException; - -/** - * This exception is thrown if a Constraint implementation can not be found. - */ -public class ConstraintImplementationNotFoundException - extends InvalidApplicationException -{ - public ConstraintImplementationNotFoundException( String message ) - { - super( message ); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/zest/api/constraint/ConstraintViolation.java ---------------------------------------------------------------------- diff --git a/core/api/src/main/java/org/apache/zest/api/constraint/ConstraintViolation.java b/core/api/src/main/java/org/apache/zest/api/constraint/ConstraintViolation.java deleted file mode 100644 index 44b4830..0000000 --- a/core/api/src/main/java/org/apache/zest/api/constraint/ConstraintViolation.java +++ /dev/null @@ -1,58 +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.zest.api.constraint; - -import java.io.Serializable; -import java.lang.annotation.Annotation; - -/** - * When a constraint violation has occurred (ie Constraint.isValid has returned false) it - * is put in a collection of all violations that have occurred for this value check. - */ -public final class ConstraintViolation - implements Serializable -{ - private String name; - private final Annotation constraint; - private final Object value; - - public ConstraintViolation( String name, Annotation constraint, Object value ) - { - this.name = name; - this.constraint = constraint; - this.value = value; - } - - public String name() - { - return name; - } - - public Annotation constraint() - { - return constraint; - } - - public Object value() - { - return value; - } -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/zest/api/constraint/ConstraintViolationException.java ---------------------------------------------------------------------- diff --git a/core/api/src/main/java/org/apache/zest/api/constraint/ConstraintViolationException.java b/core/api/src/main/java/org/apache/zest/api/constraint/ConstraintViolationException.java deleted file mode 100644 index b883f7d..0000000 --- a/core/api/src/main/java/org/apache/zest/api/constraint/ConstraintViolationException.java +++ /dev/null @@ -1,261 +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.zest.api.constraint; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Member; -import java.lang.reflect.Type; -import java.text.MessageFormat; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Locale; -import java.util.MissingResourceException; -import java.util.ResourceBundle; -import java.util.stream.Collectors; -import java.util.stream.Stream; -import org.apache.zest.api.composite.Composite; -import org.apache.zest.api.identity.Identity; -import org.apache.zest.api.util.Classes; - -import static java.util.stream.Collectors.joining; - -/** - * This Exception is thrown when there is one or more Constraint Violations in a method - * call. - * <p> - * The Constraint Violations are aggregated per method, and this exception will contain those - * violations, together with the Composite instance it happened on as well as the Method that - * was invoked. The Exception also has support for localized messages of these violations. - * </p> - */ -public class ConstraintViolationException - extends IllegalArgumentException -{ - private static final long serialVersionUID = 1L; - - private final Collection<ConstraintViolation> constraintViolations; - private String methodName; - private String mixinTypeName; - private String instanceToString; - private List<? extends Type> instanceTypes; - - public ConstraintViolationException( Composite instance, Member method, - Collection<ConstraintViolation> constraintViolations - ) - { - this( instance.toString(), Classes.interfacesOf( instance.getClass() ), method, constraintViolations ); - } - - public ConstraintViolationException( String instanceToString, - Stream<? extends Type> instanceTypes, - Member method, - Collection<ConstraintViolation> violations - ) - { - this.instanceToString = instanceToString; - this.instanceTypes = instanceTypes.collect( Collectors.toList() ); - mixinTypeName = method.getDeclaringClass().getName(); - methodName = method.getName(); - this.constraintViolations = violations; - } - - public ConstraintViolationException( Identity identity, - List<? extends Type> instanceTypes, - String mixinTypeName, - String methodName, - Collection<ConstraintViolation> violations - ) - { - this.instanceToString = identity.toString(); - this.instanceTypes = instanceTypes; - this.mixinTypeName = mixinTypeName; - this.methodName = methodName; - this.constraintViolations = violations; - } - - public Collection<ConstraintViolation> constraintViolations() - { - return constraintViolations; - } - - /** - * Creates localized messages of all the constraint violations that has occured. - * <p> - * The key "<code>zest.constraint.<i><strong>CompositeType</strong></i>.<i><strong>methodName</strong></i></code>" - * will be used to lookup the text formatting - * pattern from the ResourceBundle, where <strong><code><i>CompositeType</i></code></strong> is the - * class name of the Composite where the constraint was violated. If such key does not exist, then the - * key "<code>zest.constraint</code>" will be used, and if that one also doesn't exist, or - * the resourceBundle argument is null, then the default patterns will be used; - * </p> - * <table summary="Localization of constraint vioations."> - * <tr><th>Type of Composite</th><th>Pattern used</th></tr> - * <tr><td>Composite</td> - * <td><code>Constraint Violation in {2}.{3} with constraint {4}, in composite \n{0} of type {1}</code></td> - * </tr> - * <tr><td>EntityComposite</td> - * <td><code>Constraint Violation in {2}.{3} with constraint {4}, in entity {1}[id={0}]</code></td> - * </tr> - * <tr><td>ServiceComposite</td> - * <td><code>Constraint Violation in {2}.{3} with constraint {4}, in service {0}</code></td> - * </tr> - * </table> - * Then format each ConstraintViolation according to such pattern, where the following argument are passed; - * <table summary="List of arguments available."><tr><th>Arg</th><th>Value</th></tr> - * <tr> - * <td>{0}</td> - * <td>Composite instance toString()</td> - * </tr> - * <tr> - * <td>{1}</td> - * <td>CompositeType class name</td> - * </tr> - * <tr> - * <td>{2}</td> - * <td>MixinType class name</td> - * </tr> - * <tr> - * <td>{3}</td> - * <td>MixinType method name</td> - * </tr> - * <tr> - * <td>{4}</td> - * <td>Annotation toString()</td> - * </tr> - * <tr> - * <td>{5}</td> - * <td>toString() of value passed as the argument, or "null" text if argument was null.</td> - * </tr> - * </table> - * <p> - * <b>NOTE!!!</b> This class is still under construction and will be modified further. - * </p> - * - * @param bundle The ResourceBundle for Localization, or null if default formatting and locale to be used. - * - * @return An array of localized messages of the violations incurred. - */ - public String[] localizedMessagesFrom( ResourceBundle bundle ) - { - String pattern = "Constraint violation in {0}.{1} for method ''{3}'' with constraint \"{4}({6})\", for value ''{5}''"; - - ArrayList<String> list = new ArrayList<>(); - for( ConstraintViolation violation : constraintViolations ) - { - Locale locale; - if( bundle != null ) - { - try - { - pattern = bundle.getString( "zest.constraint." + mixinTypeName + "." + methodName ); - } - catch( MissingResourceException e1 ) - { - try - { - pattern = bundle.getString( "zest.constraint" ); - } - catch( MissingResourceException e2 ) - { - // ignore. The default pattern will be used. - } - } - locale = bundle.getLocale(); - } - else - { - locale = Locale.getDefault(); - } - MessageFormat format = new MessageFormat( pattern, locale ); - - Annotation annotation = violation.constraint(); - String name = violation.name(); - Object value = violation.value(); - String classes; - if( instanceTypes.stream().count() == 1 ) - { - Type type = instanceTypes.stream().findFirst().get(); - classes = Classes.RAW_CLASS.apply( type ).getSimpleName(); - } - else - { - classes = "[" + instanceTypes.stream() - .map( Classes.RAW_CLASS ) - .map( Class::getSimpleName ).collect( joining( "," ) ) + "]"; - } - Object[] args = new Object[] - { - instanceToString, - classes, - mixinTypeName, - methodName, - annotation.toString(), - "" + value, - name - }; - StringBuffer text = new StringBuffer(); - format.format( args, text, null ); - list.add( text.toString() ); - } - String[] result = new String[ list.size() ]; - list.toArray( result ); - return result; - } - - public String localizedMessage() - { - String[] messages = localizedMessagesFrom( null ); - StringBuilder result = new StringBuilder(); - boolean first = true; - for( String message : messages ) - { - if( !first ) - { - result.append( ',' ); - } - first = false; - result.append( message ); - } - return result.toString(); - } - - @Override - public String getLocalizedMessage() - { - return localizedMessage(); - } - - @Override - public String getMessage() - { - return localizedMessage(); - } - - public String methodName() - { - return methodName; - } - - public String mixinTypeName() - { - return mixinTypeName; - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/zest/api/constraint/Constraints.java ---------------------------------------------------------------------- diff --git a/core/api/src/main/java/org/apache/zest/api/constraint/Constraints.java b/core/api/src/main/java/org/apache/zest/api/constraint/Constraints.java deleted file mode 100644 index d1931a9..0000000 --- a/core/api/src/main/java/org/apache/zest/api/constraint/Constraints.java +++ /dev/null @@ -1,42 +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.zest.api.constraint; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * This annotation is used by composites and mixins to declare what Constraints - * can be applied in the Composite. - * <p> - * Constraints implement the {@link Constraint} interface - * </p> - */ -@Retention( RetentionPolicy.RUNTIME ) -@Target( { ElementType.TYPE } ) -@Documented -public @interface Constraints -{ - Class<? extends Constraint<?, ?>>[] value(); -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/zest/api/constraint/ConstraintsDescriptor.java ---------------------------------------------------------------------- diff --git a/core/api/src/main/java/org/apache/zest/api/constraint/ConstraintsDescriptor.java b/core/api/src/main/java/org/apache/zest/api/constraint/ConstraintsDescriptor.java deleted file mode 100644 index bfe5622..0000000 --- a/core/api/src/main/java/org/apache/zest/api/constraint/ConstraintsDescriptor.java +++ /dev/null @@ -1,28 +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.zest.api.constraint; - -/** - * Constraints Descriptor. - */ -public interface ConstraintsDescriptor -{ -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/zest/api/constraint/Name.java ---------------------------------------------------------------------- diff --git a/core/api/src/main/java/org/apache/zest/api/constraint/Name.java b/core/api/src/main/java/org/apache/zest/api/constraint/Name.java deleted file mode 100644 index a77a965..0000000 --- a/core/api/src/main/java/org/apache/zest/api/constraint/Name.java +++ /dev/null @@ -1,37 +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.zest.api.constraint; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Annotation for parameter names. This is used to add extra information for constraint exception. - */ -@Retention( RetentionPolicy.RUNTIME ) -@Target( { ElementType.PARAMETER } ) -@Documented -public @interface Name -{ - String value(); -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/zest/api/constraint/package.html ---------------------------------------------------------------------- diff --git a/core/api/src/main/java/org/apache/zest/api/constraint/package.html b/core/api/src/main/java/org/apache/zest/api/constraint/package.html deleted file mode 100644 index 87e14b7..0000000 --- a/core/api/src/main/java/org/apache/zest/api/constraint/package.html +++ /dev/null @@ -1,24 +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. - ~ - ~ - --> -<html> - <body> - <h2>Constraint API.</h2> - </body> -</html> http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/zest/api/entity/Aggregated.java ---------------------------------------------------------------------- diff --git a/core/api/src/main/java/org/apache/zest/api/entity/Aggregated.java b/core/api/src/main/java/org/apache/zest/api/entity/Aggregated.java deleted file mode 100644 index f63e1b3..0000000 --- a/core/api/src/main/java/org/apache/zest/api/entity/Aggregated.java +++ /dev/null @@ -1,37 +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.zest.api.entity; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Marks an association as aggregating the referenced Entities - */ -@Retention( RetentionPolicy.RUNTIME ) -@Target( { ElementType.METHOD } ) -@Documented -public @interface Aggregated -{ -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/zest/api/entity/EntityBuilder.java ---------------------------------------------------------------------- diff --git a/core/api/src/main/java/org/apache/zest/api/entity/EntityBuilder.java b/core/api/src/main/java/org/apache/zest/api/entity/EntityBuilder.java deleted file mode 100644 index 2c574d6..0000000 --- a/core/api/src/main/java/org/apache/zest/api/entity/EntityBuilder.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.zest.api.entity; - -import org.apache.zest.api.common.ConstructionException; - -/** - * EntityBuilders are used to instantiate EntityComposites. They can be acquired from - * {@link org.apache.zest.api.unitofwork.UnitOfWork#newEntityBuilder(Class)} and allows the client - * to provide additional settings before instantiating the Composite. - * - * After calling newInstance() the builder becomes invalid, and may not be called again. - */ -public interface EntityBuilder<T> -{ - /** - * Get a representation of the state for the new Composite. - * It is possible to access and update properties and associations, - * even immutable ones since the builder represents the initial state. - * - * @return a proxy implementing the Composite type - */ - T instance(); - - /** - * Get a representation of the state of the given type for the new Composite. - * This is primarily used if you want to provide state for a private mixin type. - * - * @param mixinType the mixin which you want to provide state for - * - * @return a proxy implementing the given mixin type - */ - <K> K instanceFor( Class<K> mixinType ); - - /** - * Create a new Entity instance. - * - * @return a new Entity instance - * - * @throws org.apache.zest.api.common.ConstructionException - * thrown if it was not possible to instantiate the Composite - * @throws LifecycleException if the entity could not be created - */ - T newInstance() - throws ConstructionException, LifecycleException; -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/zest/api/entity/EntityBuilderTemplate.java ---------------------------------------------------------------------- diff --git a/core/api/src/main/java/org/apache/zest/api/entity/EntityBuilderTemplate.java b/core/api/src/main/java/org/apache/zest/api/entity/EntityBuilderTemplate.java deleted file mode 100644 index 45aa497..0000000 --- a/core/api/src/main/java/org/apache/zest/api/entity/EntityBuilderTemplate.java +++ /dev/null @@ -1,44 +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.zest.api.entity; - -import org.apache.zest.api.structure.Module; - -/** - * EntityBuilderTemplate. - */ -public abstract class EntityBuilderTemplate<T> -{ - Class<T> type; - - protected EntityBuilderTemplate( Class<T> type ) - { - this.type = type; - } - - protected abstract void build( T prototype ); - - public T newInstance( Module module ) - { - EntityBuilder<T> builder = module.unitOfWorkFactory().currentUnitOfWork().newEntityBuilder( type ); - build( builder.instance() ); - return builder.newInstance(); - } -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/zest/api/entity/EntityComposite.java ---------------------------------------------------------------------- diff --git a/core/api/src/main/java/org/apache/zest/api/entity/EntityComposite.java b/core/api/src/main/java/org/apache/zest/api/entity/EntityComposite.java deleted file mode 100644 index 44de095..0000000 --- a/core/api/src/main/java/org/apache/zest/api/entity/EntityComposite.java +++ /dev/null @@ -1,36 +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.zest.api.entity; - -import org.apache.zest.api.association.AssociationMixin; -import org.apache.zest.api.association.ManyAssociationMixin; -import org.apache.zest.api.association.NamedAssociationMixin; -import org.apache.zest.api.composite.Composite; -import org.apache.zest.api.identity.HasIdentity; -import org.apache.zest.api.mixin.Mixins; - -/** - * EntityComposites are Composites that has mutable state persisted in EntityStores and equality defined from its - * reference. - */ -@Mixins( { AssociationMixin.class, ManyAssociationMixin.class, NamedAssociationMixin.class } ) -public interface EntityComposite extends HasIdentity, Composite -{ -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/zest/api/entity/EntityDescriptor.java ---------------------------------------------------------------------- diff --git a/core/api/src/main/java/org/apache/zest/api/entity/EntityDescriptor.java b/core/api/src/main/java/org/apache/zest/api/entity/EntityDescriptor.java deleted file mode 100644 index 42ac4a4..0000000 --- a/core/api/src/main/java/org/apache/zest/api/entity/EntityDescriptor.java +++ /dev/null @@ -1,37 +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.zest.api.entity; - -import org.apache.zest.api.association.AssociationStateDescriptor; -import org.apache.zest.api.composite.CompositeDescriptor; -import org.apache.zest.api.composite.StatefulCompositeDescriptor; - -/** - * Entity Descriptor. - */ -public interface EntityDescriptor - extends CompositeDescriptor, StatefulCompositeDescriptor -{ - @Override - AssociationStateDescriptor state(); - - boolean queryable(); -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/zest/api/entity/EntityReference.java ---------------------------------------------------------------------- diff --git a/core/api/src/main/java/org/apache/zest/api/entity/EntityReference.java b/core/api/src/main/java/org/apache/zest/api/entity/EntityReference.java deleted file mode 100644 index a6a5e0e..0000000 --- a/core/api/src/main/java/org/apache/zest/api/entity/EntityReference.java +++ /dev/null @@ -1,123 +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.zest.api.entity; - -import java.io.Serializable; -import java.util.Objects; -import org.apache.zest.api.identity.Identity; -import org.apache.zest.api.identity.StringIdentity; -import org.apache.zest.api.util.NullArgumentException; - -/** - * An EntityReference is reference of a specific Entity instance. - * <p>When stringified, the reference is used as-is. Example:</p> - * <pre>123456-abcde</pre> - */ -public final class EntityReference - implements Serializable -{ - /** - * Parse an Entity reference to an EntityReference. - * - * @param identityString the EntityReference reference - * @return the EntityReference represented by the given reference - */ - public static EntityReference parseEntityReference(String identityString) - { - return new EntityReference( new StringIdentity( identityString ) ); - } - - /** - * @param object an EntityComposite - * @return the EntityReference for the given EntityComposite - */ - public static EntityReference entityReferenceFor(Object object) - { - return new EntityReference(((EntityComposite) object).identity().get()); - } - - public static EntityReference create(Identity identity) - { - if (identity == null) - { - return null; - } - return new EntityReference(identity); - } - - private static final long serialVersionUID = 1L; - - private Identity identity; - - /** - * @param identity reference reference - * @throws NullArgumentException if reference is null or empty - */ - private EntityReference( Identity identity ) - { - Objects.requireNonNull(identity,"reference must not be null"); - this.identity = identity; - } - - /** - * - * @return The reference of the Entity that this EntityReference.is referring to - */ - public final Identity identity() - { - return identity; - } - - /** - * @return An URI representation of this EntityReference. - */ - public String toURI() - { - return "urn:zest:entity:" + identity; - } - - @Override - public boolean equals(Object o) - { - if (this == o) - { - return true; - } - if (o == null || getClass() != o.getClass()) - { - return false; - } - EntityReference that = (EntityReference) o; - return identity.equals(that.identity); - } - - @Override - public int hashCode() - { - return identity.hashCode(); - } - - @Override - public String toString() - { - return identity.toString(); - } -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/zest/api/entity/Lifecycle.java ---------------------------------------------------------------------- diff --git a/core/api/src/main/java/org/apache/zest/api/entity/Lifecycle.java b/core/api/src/main/java/org/apache/zest/api/entity/Lifecycle.java deleted file mode 100644 index c360b25..0000000 --- a/core/api/src/main/java/org/apache/zest/api/entity/Lifecycle.java +++ /dev/null @@ -1,87 +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.zest.api.entity; - -/** - * Lifecycle interface for all Composites. - * <p> - * This Lifecycle interface is a built-in feature of the Polygene runtime, similar to the Initializable interface. - * Any Mixin that implements this interface AND is part of an EntityComposite will have these two methods called - * upon creation/removal of the EntityComposite instance to/from the EntityStore. Meaning, the create method is called - * only when the identifiable EntityComposite is created the first time, and not when it is read from its persisted - * state and created into memory. - * </p> - * <p> - * Example; - * </p> - * <pre><code> - * public interface System - * { - * Property<User> admin(); - * } - * - * public class SystemAdminMixin<LifeCycle> - * implements System, Lifecyle, ... - * { - * @Structure private UnitOfWork uow; - * @This private Identity meAsIdentity; - * - * public void create() - * { - * String thisId = meAsIdentity.reference().get(); - * EntityBuilder builder = uow.newEntityBuilder( thisId + ":1", UserComposite.class ); - * User admin = builder.newInstance(); - * admin.set( admin ); - * } - * - * public void remove() - * { - * uow.remove( admin.get() ); - * } - * } - * - * @Mixins( SystemAdminMixin.class ) - * public interface SystemEntity extends System, EntityComposite - * {} - * - * </code></pre> - */ -public interface Lifecycle -{ - /** - * Creation callback method. - * <p> - * Called by the Polygene runtime before the newInstance of the entity completes, before the constraints are checked, - * allowing for additional initialization. - * </p> - * @throws Exception if the entity could not be created - */ - void create() throws Exception; - - /** - * Removal callback method. - * <p> - * Called by the Polygene runtime before the entity is removed from the system, allowing - * for clean-up operations. - * </p> - * @throws Exception if the entity could not be removed - */ - void remove() throws Exception; -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/zest/api/entity/LifecycleException.java ---------------------------------------------------------------------- diff --git a/core/api/src/main/java/org/apache/zest/api/entity/LifecycleException.java b/core/api/src/main/java/org/apache/zest/api/entity/LifecycleException.java deleted file mode 100644 index c4b5957..0000000 --- a/core/api/src/main/java/org/apache/zest/api/entity/LifecycleException.java +++ /dev/null @@ -1,39 +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.zest.api.entity; - -/** - * Thrown if Lifecycle invocation fails - */ -public class LifecycleException - extends RuntimeException -{ - private static final long serialVersionUID = 1L; - - public LifecycleException() - { - } - - public LifecycleException( String message, Throwable cause ) - { - super( message, cause ); - } -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/zest/api/entity/Queryable.java ---------------------------------------------------------------------- diff --git a/core/api/src/main/java/org/apache/zest/api/entity/Queryable.java b/core/api/src/main/java/org/apache/zest/api/entity/Queryable.java deleted file mode 100644 index 132789d..0000000 --- a/core/api/src/main/java/org/apache/zest/api/entity/Queryable.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.zest.api.entity; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * This annotation is used to mark entity types or properties/associations that are indexable. - */ -@Retention( RetentionPolicy.RUNTIME ) -@Target( { ElementType.TYPE, ElementType.METHOD } ) -@Documented -public @interface Queryable -{ - boolean value() default true; -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/zest/api/entity/package.html ---------------------------------------------------------------------- diff --git a/core/api/src/main/java/org/apache/zest/api/entity/package.html b/core/api/src/main/java/org/apache/zest/api/entity/package.html deleted file mode 100644 index 39a3223..0000000 --- a/core/api/src/main/java/org/apache/zest/api/entity/package.html +++ /dev/null @@ -1,24 +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. - ~ - ~ - --> -<html> - <body> - <h2>Entity API.</h2> - </body> -</html> http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/zest/api/event/package.html ---------------------------------------------------------------------- diff --git a/core/api/src/main/java/org/apache/zest/api/event/package.html b/core/api/src/main/java/org/apache/zest/api/event/package.html deleted file mode 100644 index 4972ae6..0000000 --- a/core/api/src/main/java/org/apache/zest/api/event/package.html +++ /dev/null @@ -1,24 +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. - ~ - ~ - --> -<html> - <body> - <h2>Event API.</h2> - </body> -</html> http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/zest/api/identity/HasIdentity.java ---------------------------------------------------------------------- diff --git a/core/api/src/main/java/org/apache/zest/api/identity/HasIdentity.java b/core/api/src/main/java/org/apache/zest/api/identity/HasIdentity.java deleted file mode 100644 index c256690..0000000 --- a/core/api/src/main/java/org/apache/zest/api/identity/HasIdentity.java +++ /dev/null @@ -1,76 +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.zest.api.identity; - -import java.lang.reflect.Method; -import org.apache.zest.api.common.QualifiedName; -import org.apache.zest.api.injection.scope.State; -import org.apache.zest.api.mixin.Mixins; -import org.apache.zest.api.property.Immutable; -import org.apache.zest.api.property.Property; - -/** - * This interface provides the identity of the object which may be used - * to store the state in a database. It is not the responsibility of the - * framework to come up with a good identity string. - */ -@Mixins( HasIdentity.HasIdentityMixin.class ) -public interface HasIdentity -{ - Method IDENTITY_METHOD = HasIdentityMixin.identityMethod(); - QualifiedName IDENTITY_STATE_NAME = HasIdentityMixin.stateName(); - - @Immutable - Property<Identity> identity(); - - /** - * Default Identity implementation. - */ - class HasIdentityMixin - implements HasIdentity - { - @State - private Property<Identity> identity; - - - @Override - public Property<Identity> identity() - { - return identity; - } - - private static QualifiedName stateName() - { - return QualifiedName.fromAccessor( identityMethod() ); - } - - private static Method identityMethod() - { - try - { - return HasIdentity.class.getMethod( "identity" ); - } - catch( NoSuchMethodException e ) - { - throw new InternalError( "Polygene Core Runtime codebase is corrupted." ); - } - } - } -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/zest/api/identity/Identifiable.java ---------------------------------------------------------------------- diff --git a/core/api/src/main/java/org/apache/zest/api/identity/Identifiable.java b/core/api/src/main/java/org/apache/zest/api/identity/Identifiable.java deleted file mode 100644 index f111570..0000000 --- a/core/api/src/main/java/org/apache/zest/api/identity/Identifiable.java +++ /dev/null @@ -1,25 +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.zest.api.identity; - -public interface Identifiable -{ - Identity identity(); -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/zest/api/identity/Identity.java ---------------------------------------------------------------------- diff --git a/core/api/src/main/java/org/apache/zest/api/identity/Identity.java b/core/api/src/main/java/org/apache/zest/api/identity/Identity.java deleted file mode 100644 index 6cf549e..0000000 --- a/core/api/src/main/java/org/apache/zest/api/identity/Identity.java +++ /dev/null @@ -1,33 +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.zest.api.identity; - -/** - * Representation of an Identity. - * Identity is an opaque, immutable data type. - * Identity is a very central concept in any domain model. - * - */ -public interface Identity -{ - String toString(); - - byte[] toBytes(); -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/zest/api/identity/IdentityGenerator.java ---------------------------------------------------------------------- diff --git a/core/api/src/main/java/org/apache/zest/api/identity/IdentityGenerator.java b/core/api/src/main/java/org/apache/zest/api/identity/IdentityGenerator.java deleted file mode 100644 index d15c8ab..0000000 --- a/core/api/src/main/java/org/apache/zest/api/identity/IdentityGenerator.java +++ /dev/null @@ -1,39 +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.zest.api.identity; - -import org.apache.zest.api.mixin.Mixins; - -/** - * Generator for identities of EntityComposite's. - */ -@Mixins( UuidGeneratorMixin.class ) -public interface IdentityGenerator -{ - /** - * Generate a new id for the given Composite type - * - * @param compositeType the type of composite - * - * @return a new reference - */ - Identity generate( Class<?> compositeType ); - -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/zest/api/identity/StringIdentity.java ---------------------------------------------------------------------- diff --git a/core/api/src/main/java/org/apache/zest/api/identity/StringIdentity.java b/core/api/src/main/java/org/apache/zest/api/identity/StringIdentity.java deleted file mode 100644 index a3e5002..0000000 --- a/core/api/src/main/java/org/apache/zest/api/identity/StringIdentity.java +++ /dev/null @@ -1,86 +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.zest.api.identity; - -import java.nio.charset.StandardCharsets; -import java.util.Objects; - -public class StringIdentity - implements Identity -{ - private final String value; - - public StringIdentity(String value) - { - Objects.requireNonNull( value, "Identity can not be null." ); - this.value = value; - } - - public StringIdentity(byte[] bytes) - { - value = new String(bytes, StandardCharsets.UTF_8); - } - - public String value() - { - return value; - } - - @Override - public byte[] toBytes() - { - return value.getBytes(StandardCharsets.UTF_8); - } - - @Override - public String toString() - { - return value; - } - - public static Identity fromString(String serializedState) - { - return new StringIdentity( serializedState ); - } - - @Override - public boolean equals(Object o) - { - if (this == o) - { - return true; - } - if (o == null || getClass() != o.getClass()) - { - return false; - } - - StringIdentity that = (StringIdentity) o; - - return value.equals(that.value); - - } - - @Override - public int hashCode() - { - return value.hashCode(); - } -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/zest/api/identity/UuidGeneratorMixin.java ---------------------------------------------------------------------- diff --git a/core/api/src/main/java/org/apache/zest/api/identity/UuidGeneratorMixin.java b/core/api/src/main/java/org/apache/zest/api/identity/UuidGeneratorMixin.java deleted file mode 100644 index 5caddc0..0000000 --- a/core/api/src/main/java/org/apache/zest/api/identity/UuidGeneratorMixin.java +++ /dev/null @@ -1,32 +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.zest.api.identity; - -import java.util.UUID; - -public class UuidGeneratorMixin - implements IdentityGenerator -{ - @Override - public Identity generate(Class<?> compositeType) - { - return StringIdentity.fromString(UUID.randomUUID().toString()); - } -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/zest/api/injection/InjectionScope.java ---------------------------------------------------------------------- diff --git a/core/api/src/main/java/org/apache/zest/api/injection/InjectionScope.java b/core/api/src/main/java/org/apache/zest/api/injection/InjectionScope.java deleted file mode 100644 index eb8ec5f..0000000 --- a/core/api/src/main/java/org/apache/zest/api/injection/InjectionScope.java +++ /dev/null @@ -1,37 +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.zest.api.injection; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * This is used to annotate annotation types which are used for injection. - * Each scope signifies a particular scope from which the injection value should be taken. - */ -@Retention( RetentionPolicy.RUNTIME ) -@Target( { ElementType.ANNOTATION_TYPE } ) -@Documented -public @interface InjectionScope -{ -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/zest/api/injection/package.html ---------------------------------------------------------------------- diff --git a/core/api/src/main/java/org/apache/zest/api/injection/package.html b/core/api/src/main/java/org/apache/zest/api/injection/package.html deleted file mode 100644 index 155a5e4..0000000 --- a/core/api/src/main/java/org/apache/zest/api/injection/package.html +++ /dev/null @@ -1,24 +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. - ~ - ~ - --> -<html> - <body> - <h2>Dependency Injection API.</h2> - </body> -</html> http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/zest/api/injection/scope/Invocation.java ---------------------------------------------------------------------- diff --git a/core/api/src/main/java/org/apache/zest/api/injection/scope/Invocation.java b/core/api/src/main/java/org/apache/zest/api/injection/scope/Invocation.java deleted file mode 100644 index f83b86f..0000000 --- a/core/api/src/main/java/org/apache/zest/api/injection/scope/Invocation.java +++ /dev/null @@ -1,55 +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.zest.api.injection.scope; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; -import org.apache.zest.api.injection.InjectionScope; - -/** - * Annotation to denote the injection of a - * invocation specific resource. - * These include: - * <pre><code> - * - The Method being invoked. - * - * - An AnnotationElement with annotations - * from both mixin type, mixin - * implementation. - * - * - An Annotation of a specific type - * </code></pre> - * Examples: - * <pre><code> - * @Invocation Method theInvokedMethod - * @Invocation AnnotationElement annotations - * @Invocation Matches matchesAnnotation - * </code></pre> - */ -@Retention( RetentionPolicy.RUNTIME ) -@Target( { ElementType.FIELD, ElementType.PARAMETER } ) -@Documented -@InjectionScope -public @interface Invocation -{ -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/zest/api/injection/scope/Service.java ---------------------------------------------------------------------- diff --git a/core/api/src/main/java/org/apache/zest/api/injection/scope/Service.java b/core/api/src/main/java/org/apache/zest/api/injection/scope/Service.java deleted file mode 100644 index 65eee4d..0000000 --- a/core/api/src/main/java/org/apache/zest/api/injection/scope/Service.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.zest.api.injection.scope; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; -import org.apache.zest.api.injection.InjectionScope; - -/** - * Annotation to denote the injection of a service dependency into a Fragment. - * <p> - * Examples: - * </p> - * <pre><code> - * @Service MyService service - * @Service Iterable<MyService> services - * @Service ServiceReference<MyService> serviceRef - * @Service Iterable<ServiceReference<MyService>> serviceRefs - * </code></pre> - */ -@Retention( RetentionPolicy.RUNTIME ) -@Target( { ElementType.FIELD, ElementType.PARAMETER } ) -@Documented -@InjectionScope -public @interface Service -{ -} - http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/zest/api/injection/scope/State.java ---------------------------------------------------------------------- diff --git a/core/api/src/main/java/org/apache/zest/api/injection/scope/State.java b/core/api/src/main/java/org/apache/zest/api/injection/scope/State.java deleted file mode 100644 index 853da83..0000000 --- a/core/api/src/main/java/org/apache/zest/api/injection/scope/State.java +++ /dev/null @@ -1,54 +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.zest.api.injection.scope; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; -import org.apache.zest.api.injection.InjectionScope; - -/** - * Annotation to denote the injection of a property, association or - * StateHolder. - * <pre><code> - * @State Property<StringState propertyName; - * @State Association<MyEntityState associationName; - * @State ManyAssociation<MyEntityState manyAssociationName; - * @State NamedAssociation<MyEntityState namedAssociationName; - * @State StateHolder state; - * @State AssociationStateHolder associationState; - * </code></pre> - */ -@Retention( RetentionPolicy.RUNTIME ) -@Target( { ElementType.FIELD, ElementType.PARAMETER } ) -@Documented -@InjectionScope -public @interface State -{ - /** - * Name of the property or association. - * If not set then name will be name of field. - * - * @return the name - */ - public abstract String value() default ""; -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/zest/api/injection/scope/Structure.java ---------------------------------------------------------------------- diff --git a/core/api/src/main/java/org/apache/zest/api/injection/scope/Structure.java b/core/api/src/main/java/org/apache/zest/api/injection/scope/Structure.java deleted file mode 100644 index 2a9916c..0000000 --- a/core/api/src/main/java/org/apache/zest/api/injection/scope/Structure.java +++ /dev/null @@ -1,54 +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.zest.api.injection.scope; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; -import org.apache.zest.api.injection.InjectionScope; - -/** - * Annotation to denote the injection of a - * resource specific for the module which the - * injected object/fragment is instantiated in. - * <p> - * Valid types are: - * </p> - * <pre><code> - * - TransientBuilderFactory - * - ObjectBuilderFactory - * - UnitOfWorkFactory - * - ServiceFinder - * - Module - * - Layer - * - Application - * - PolygeneAPI - * - PolygeneSPI - * </code></pre> - */ -@Retention( RetentionPolicy.RUNTIME ) -@Target( { ElementType.FIELD, ElementType.PARAMETER } ) -@Documented -@InjectionScope -public @interface Structure -{ -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/zest/api/injection/scope/This.java ---------------------------------------------------------------------- diff --git a/core/api/src/main/java/org/apache/zest/api/injection/scope/This.java b/core/api/src/main/java/org/apache/zest/api/injection/scope/This.java deleted file mode 100644 index 995ad8b..0000000 --- a/core/api/src/main/java/org/apache/zest/api/injection/scope/This.java +++ /dev/null @@ -1,47 +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.zest.api.injection.scope; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; -import org.apache.zest.api.injection.InjectionScope; - -/** - * Annotation to denote the injection of a reference to the same Composite - * as the fragment is a part of. - * <p> - * If the Composite type does not implement the type of the field or parameter - * then it will be referencing a private mixin. - * </p> - * <p> - * Calls to the reference will have the same semantics as calls to the Composite itself. - * Specifically the same set of Modifiers will be used. - * </p> - */ -@Retention( RetentionPolicy.RUNTIME ) -@Target( { ElementType.FIELD, ElementType.PARAMETER } ) -@Documented -@InjectionScope -public @interface This -{ -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/zest/api/injection/scope/Uses.java ---------------------------------------------------------------------- diff --git a/core/api/src/main/java/org/apache/zest/api/injection/scope/Uses.java b/core/api/src/main/java/org/apache/zest/api/injection/scope/Uses.java deleted file mode 100644 index 1512167..0000000 --- a/core/api/src/main/java/org/apache/zest/api/injection/scope/Uses.java +++ /dev/null @@ -1,45 +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.zest.api.injection.scope; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; -import org.apache.zest.api.injection.InjectionScope; - -/** - * Annotation to denote the injection of a dependency to be used by a Mixin. The injected - * object is provided either by the TransientBuilder.uses() declarations, or if an instance of the appropriate types is not - * found, then a new Transient or Object is instantiated. - * Call {@link org.apache.zest.api.composite.TransientBuilder#use} to provide the instance - * to be injected. - * - * Example: - * <pre>@Uses SomeType someInstance</pre> - */ -@Retention( RetentionPolicy.RUNTIME ) -@Target( { ElementType.PARAMETER, ElementType.FIELD } ) -@Documented -@InjectionScope -public @interface Uses -{ -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/zest/api/injection/scope/package.html ---------------------------------------------------------------------- diff --git a/core/api/src/main/java/org/apache/zest/api/injection/scope/package.html b/core/api/src/main/java/org/apache/zest/api/injection/scope/package.html deleted file mode 100644 index 10f4f1c..0000000 --- a/core/api/src/main/java/org/apache/zest/api/injection/scope/package.html +++ /dev/null @@ -1,24 +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. - ~ - ~ - --> -<html> - <body> - <h2>Dependency Injection Scopes.</h2> - </body> -</html> http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/zest/api/metrics/Metric.java ---------------------------------------------------------------------- diff --git a/core/api/src/main/java/org/apache/zest/api/metrics/Metric.java b/core/api/src/main/java/org/apache/zest/api/metrics/Metric.java deleted file mode 100644 index 14fe767..0000000 --- a/core/api/src/main/java/org/apache/zest/api/metrics/Metric.java +++ /dev/null @@ -1,28 +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.zest.api.metrics; - -/** - * Marker interface for all Metric types. - */ -public interface Metric -{ -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/zest/api/metrics/MetricNames.java ---------------------------------------------------------------------- diff --git a/core/api/src/main/java/org/apache/zest/api/metrics/MetricNames.java b/core/api/src/main/java/org/apache/zest/api/metrics/MetricNames.java deleted file mode 100644 index a924d4b..0000000 --- a/core/api/src/main/java/org/apache/zest/api/metrics/MetricNames.java +++ /dev/null @@ -1,95 +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.zest.api.metrics; - -import org.apache.zest.api.structure.Module; - -import java.lang.reflect.Method; -import java.util.StringJoiner; - -/** - * Metric names utilities. - */ -public class MetricNames -{ - /** - * Build a Metric name for the given fragments. - * - * @param fragments Name fragments - * @return Metric name - */ - public static String nameFor( String... fragments ) - { - StringJoiner joiner = new StringJoiner( "." ); - for( String fragment : fragments ) - { - joiner.add( fragment ); - } - return joiner.toString(); - } - - /** - * Build a Metric name for the given Module, Type and optional fragments. - * - * @param module Module - * @param type Type - * @param fragments Name fragments - * @return Metric name - */ - public static String nameFor( Module module, Class<?> type, String... fragments ) - { - StringJoiner joiner = new StringJoiner( "." ) - .add( module.layer().name() ) - .add( module.name() ) - .add( className( type ) ); - for( String fragment : fragments ) - { - joiner.add( fragment ); - } - return joiner.toString(); - } - - /** - * Build a Metric name for the given Module, Method and optional fragments. - * - * @param module Module - * @param method Method - * @param fragments Name fragments - * @return Metric name - */ - public static String nameFor( Module module, Method method, String... fragments ) - { - StringJoiner joiner = new StringJoiner( "." ) - .add( module.layer().name() ) - .add( module.name() ) - .add( className( method.getDeclaringClass() ) ) - .add( method.getName() ); - for( String fragment : fragments ) - { - joiner.add( fragment ); - } - return joiner.toString(); - } - - private static String className( Class<?> clazz ) - { - return clazz.getName().substring( clazz.getName().lastIndexOf( '.' ) + 1 ).replace( '$', '.' ); - } -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/1c722f44/core/api/src/main/java/org/apache/zest/api/metrics/MetricsCounter.java ---------------------------------------------------------------------- diff --git a/core/api/src/main/java/org/apache/zest/api/metrics/MetricsCounter.java b/core/api/src/main/java/org/apache/zest/api/metrics/MetricsCounter.java deleted file mode 100644 index e1ed01f..0000000 --- a/core/api/src/main/java/org/apache/zest/api/metrics/MetricsCounter.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.zest.api.metrics; - -/** - * Metrics Counter. - */ -public interface MetricsCounter extends Metric -{ - void increment(); - - void increment( int steps ); - - void decrement(); - - void decrement( int steps ); -}
