From: Tony Tkacik Date: Fri, 19 Feb 2016 13:38:25 +0000 (+0100) Subject: Remove unused obsolete concepts code. X-Git-Tag: release/boron~329 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=7c58c4ddf96b33b95519149e45089c03c21b2f47 Remove unused obsolete concepts code. Change-Id: I7898e6ced3938ff245cbc9d4861bdce23e909d30 Signed-off-by: Tony Tkacik --- diff --git a/opendaylight/commons/concepts/pom.xml b/opendaylight/commons/concepts/pom.xml deleted file mode 100644 index bec2aa9916..0000000000 --- a/opendaylight/commons/concepts/pom.xml +++ /dev/null @@ -1,58 +0,0 @@ - - - 4.0.0 - - org.opendaylight.controller - commons.opendaylight - 1.7.0-SNAPSHOT - ../../commons/opendaylight - - - concepts - 0.8.0-SNAPSHOT - bundle - - - junit - junit - - - - - - - org.apache.felix - maven-bundle-plugin - true - - - org.opendaylight.controller.concepts.transform - - ${project.basedir}/META-INF - - - - org.apache.maven.plugins - maven-checkstyle-plugin - ${checkstyle.version} - - true - controller/checkstyle.xml - - - - org.opendaylight.controller - checkstyle - 0.3.0-SNAPSHOT - - - - - - - scm:git:http://git.opendaylight.org/gerrit/controller.git - scm:git:ssh://git.opendaylight.org:29418/controller.git - HEAD - https://wiki.opendaylight.org/view/OpenDaylight_Controller:Main - - diff --git a/opendaylight/commons/concepts/src/main/java/org/opendaylight/controller/concepts/transform/Acceptor.java b/opendaylight/commons/concepts/src/main/java/org/opendaylight/controller/concepts/transform/Acceptor.java deleted file mode 100644 index 7127f00c79..0000000000 --- a/opendaylight/commons/concepts/src/main/java/org/opendaylight/controller/concepts/transform/Acceptor.java +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) 2013, 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.controller.concepts.transform; - -public interface Acceptor { - - /** - * - * @param input - * @return true if input is accepted. - */ - boolean isAcceptable(I input); -} diff --git a/opendaylight/commons/concepts/src/main/java/org/opendaylight/controller/concepts/transform/AggregateTransformer.java b/opendaylight/commons/concepts/src/main/java/org/opendaylight/controller/concepts/transform/AggregateTransformer.java deleted file mode 100644 index c89bf25c1b..0000000000 --- a/opendaylight/commons/concepts/src/main/java/org/opendaylight/controller/concepts/transform/AggregateTransformer.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.controller.concepts.transform; - -import java.util.Collection; -/** - * - * @author Tony Tkacik - * - * @param - * @param

- */ -public interface AggregateTransformer extends Transformer { - - Collection

transformAll(Collection inputs); -} diff --git a/opendaylight/commons/concepts/src/main/java/org/opendaylight/controller/concepts/transform/CompositeClassBasedTransformer.java b/opendaylight/commons/concepts/src/main/java/org/opendaylight/controller/concepts/transform/CompositeClassBasedTransformer.java deleted file mode 100644 index 2548c340d5..0000000000 --- a/opendaylight/commons/concepts/src/main/java/org/opendaylight/controller/concepts/transform/CompositeClassBasedTransformer.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.controller.concepts.transform; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - - -/** - * Transformer which aggregates multiple implementations of - * {@link InputClassBasedTransformer}. - * - * The transformation process is driven by {@link Class} of input. The selection - * of used {@link InputClassBasedTransformer} is done by using the {@link Class} - * of input as a key to select the transformer. - * - * This approach provides quick resolution of transformer, but does not support - * registering a super type of input to provide transformation support for all - * subclasses, one must register a new instance of transformer for each valid - * input class. - * - * If you need more flexible selection of transformation consider using - * {@link CompositeConditionalTransformer} which is slower but most flexible or - * {@link RuleBasedTransformer} which provides declarative approach for - * transformation. - * - * See {@link #transform(Object)} for more information about tranformation - * process. - * - * @author Tony Tkacik - * - * @param - * Input super-type - * @param

- * Product - */ -public abstract class CompositeClassBasedTransformer implements - InputClassBasedTransformer, - AggregateTransformer { - - private Map, InputClassBasedTransformer> transformers = new ConcurrentHashMap, InputClassBasedTransformer>(); - - /** - * Transforms an input into instance of Product class. - * - * The final registered transformer is the one which match following - * condition: - * - * input.getClass() == transformer.getInputClass() - * - * This means that transformers are not resolved by class hierarchy, only - * selected based on final class of the input. If you need more flexible - * selection of transformation consider using - * {@link CompositeConditionalTransformer} which is slower but more - * flexible. - * - */ - @Override - public P transform(I input) { - @SuppressWarnings("unchecked") - InputClassBasedTransformer transformer = (InputClassBasedTransformer) transformers - .get(input.getClass()); - if (transformer == null) - throw new IllegalArgumentException("Transformation of: " + input - + " is not supported"); - return transformer.transform(input); - } - - /** - * Registers a new transformer. - * - * The transformer is registered for class returned by - * {@link InputClassBasedTransformer#getInputClass()}. Only one transformer - * can be registered for particular input class. - * - */ - public void addTransformer( - InputClassBasedTransformer transformer) - throws IllegalStateException { - if (transformer == null) - throw new IllegalArgumentException("Transformer should not be null"); - if (transformer.getInputClass() == null) - throw new IllegalArgumentException( - "Transformer should specify input class."); - transformers.put(transformer.getInputClass(), transformer); - } - - /** - * Removes an registered transformer. - * - * Note: Removal is currently unsupported. - * - * @param transformer - * Tranformer to be removed. - * @throws IllegalArgumentException - * If the provided transformer is null or is not registered. - */ - public void removeTransformer( - InputClassBasedTransformer transformer) - throws IllegalArgumentException { - throw new UnsupportedOperationException("Not implemented yet"); - } - - @Override - public Collection

transformAll(Collection inputs) { - Collection

ret = new ArrayList

(); - for (I i : inputs) { - ret.add(transform(i)); - } - return ret; - } - -} diff --git a/opendaylight/commons/concepts/src/main/java/org/opendaylight/controller/concepts/transform/CompositeConditionalTransformer.java b/opendaylight/commons/concepts/src/main/java/org/opendaylight/controller/concepts/transform/CompositeConditionalTransformer.java deleted file mode 100644 index 0cdc3a156f..0000000000 --- a/opendaylight/commons/concepts/src/main/java/org/opendaylight/controller/concepts/transform/CompositeConditionalTransformer.java +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.controller.concepts.transform; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Comparator; -import java.util.Set; -import java.util.TreeSet; - -/** - * Composite transformer which aggregates multiple implementation and selects - * the one which accepts the input. - * - * - * @author Tony Tkacik - * - * @param - * Input class for transformation - * @param

- * Product of transformation - */ -public class CompositeConditionalTransformer implements - SimpleConditionalTransformer, - AggregateTransformer { - - private final Comparator> comparator = new Comparator>() { - - @Override - public int compare(TransformerWithPriority o1, - TransformerWithPriority o2) { - return Integer.valueOf(o1.priority).compareTo(Integer.valueOf(o2.priority)); - } - - }; - private final Set> transformers; - - public CompositeConditionalTransformer() { - // FIXME: Add Ordering - transformers = new TreeSet>(comparator); - } - - @Override - public boolean isAcceptable(I input) { - for (SimpleConditionalTransformer trans : transformers) { - if (trans.isAcceptable(input)) { - return true; - } - } - return false; - } - - @Override - public P transform(I input) { - for (SimpleConditionalTransformer trans : transformers) { - if (trans.isAcceptable(input)) { - return trans.transform(input); - } - } - throw new IllegalStateException( - "Transformer for provided input is not available."); - } - - public void addTransformer(SimpleConditionalTransformer transformer, - int priority) throws IllegalStateException { - if (transformer == null) { - throw new IllegalArgumentException( - "transformer should not be null."); - } - TransformerWithPriority withPriority = new TransformerWithPriority( - transformer, priority); - if (false == transformers.add(withPriority)) { - throw new IllegalStateException("transformer " + transformer - + "already registered"); - } - } - - public void removeTransformer(SimpleConditionalTransformer transformer) - throws IllegalArgumentException { - if (transformer == null) { - throw new IllegalArgumentException( - "transformer should not be null."); - } - if (false == transformers.remove(transformer)) { - throw new IllegalStateException("transformer " + transformer - + "already registered"); - } - } - - @Override - public Collection

transformAll(Collection inputs) { - Collection

ret = new ArrayList

(); - for (I i : inputs) { - ret.add(transform(i)); - } - return ret; - } - - private static class TransformerWithPriority implements - SimpleConditionalTransformer { - final int priority; - final SimpleConditionalTransformer transformer; - - public TransformerWithPriority( - SimpleConditionalTransformer transformer, int priority) { - this.priority = priority; - this.transformer = transformer; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result - + ((transformer == null) ? 0 : transformer.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - TransformerWithPriority other = (TransformerWithPriority) obj; - if (transformer == null) { - if (other.transformer != null) - return false; - } else if (!transformer.equals(other.transformer)) - return false; - return true; - } - - @Override - public boolean isAcceptable(I input) { - return transformer.isAcceptable(input); - } - - @Override - public P transform(I input) { - return transformer.transform(input); - } - - - - - - } -} diff --git a/opendaylight/commons/concepts/src/main/java/org/opendaylight/controller/concepts/transform/InputClassBasedTransformer.java b/opendaylight/commons/concepts/src/main/java/org/opendaylight/controller/concepts/transform/InputClassBasedTransformer.java deleted file mode 100644 index 1bec9bceb6..0000000000 --- a/opendaylight/commons/concepts/src/main/java/org/opendaylight/controller/concepts/transform/InputClassBasedTransformer.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.controller.concepts.transform; - -/** - * Input class based transformer - * - * {@link Transformer} which accepts / transforms only specific classes of - * input, and is useful if the selection of transformer should be based on the - * class of the input and there is one-to-one mapping between input class and - * transformer. - * - * - * @author Tony Tkacik - * - * @param - * Common supertype of input - * @param - * Concrete type of input - * @param

- * Product - */ -public interface InputClassBasedTransformer extends - Transformer { - - /** - * Returns an {@link Class} of input which is acceptable for transformation. - * - * @return {@link Class} of input which is acceptable for transformation. - */ - Class getInputClass(); -} diff --git a/opendaylight/commons/concepts/src/main/java/org/opendaylight/controller/concepts/transform/RuleBasedTransformer.java b/opendaylight/commons/concepts/src/main/java/org/opendaylight/controller/concepts/transform/RuleBasedTransformer.java deleted file mode 100644 index 9a0d8798cf..0000000000 --- a/opendaylight/commons/concepts/src/main/java/org/opendaylight/controller/concepts/transform/RuleBasedTransformer.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.controller.concepts.transform; - -import java.util.Set; - -/** - * Transformer with set of acceptance rules - * - * The transformer provides a set of {@link Acceptor}s, which could be used to - * verify if the input will produce result using the transformer. - * - * The transormer is able to produce result if ANY of associated - * {@link Acceptor}s accepted result. - * - * @author Tony Tkacik - * - * @param - * Input class for transformation - * @param

- * Product of transformation - */ -public interface RuleBasedTransformer extends Transformer { - - /** - * Set of {@link Acceptor}, which could be used to verify if the input is - * usable by transformer. - * - * The transformer is able to produce result if ANY of associated - * {@link Acceptor}s accepted result. - * - * @return Set of input acceptance rules associated to this transformer. - */ - Set> getRules(); - -} diff --git a/opendaylight/commons/concepts/src/main/java/org/opendaylight/controller/concepts/transform/SimpleConditionalTransformer.java b/opendaylight/commons/concepts/src/main/java/org/opendaylight/controller/concepts/transform/SimpleConditionalTransformer.java deleted file mode 100644 index 84770b71b1..0000000000 --- a/opendaylight/commons/concepts/src/main/java/org/opendaylight/controller/concepts/transform/SimpleConditionalTransformer.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.controller.concepts.transform; - -/** - * Simple condition-based transformer - * - * The transformer provides {@link #isAcceptable(Object)} method, - * which could be used to query transformer if the input will produce - * result. - * - * This interface is simplified version of {@link RuleBasedTransformer} - does not - * provide decoupling of Acceptance rule from transformer, and should be used only - * for simple use-cases. - * - * @author Tony Tkacik - * - * @param Input class for transformation - * @param

Product of transformation - */ -public interface SimpleConditionalTransformer extends Transformer, Acceptor { - - - /** - * Checks if the input is acceptable - * for processing by the transformer. - * - * @return true it the input is acceptable for processing by transformer. - */ - @Override - public boolean isAcceptable(I input); -} diff --git a/opendaylight/commons/concepts/src/main/java/org/opendaylight/controller/concepts/transform/Transformer.java b/opendaylight/commons/concepts/src/main/java/org/opendaylight/controller/concepts/transform/Transformer.java deleted file mode 100644 index 6f09d8b7d6..0000000000 --- a/opendaylight/commons/concepts/src/main/java/org/opendaylight/controller/concepts/transform/Transformer.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.controller.concepts.transform; - -/** - * Factory which produces product based on input object - * - * @author Tony Tkacik - * - * @param Input - * @param

Product - */ -public interface Transformer { - /** - * Transforms input into instance of product. - * - * @param input Input which drives transformation - * @return Instance of product which was created from supplied input. - */ - P transform(I input); -} diff --git a/pom.xml b/pom.xml index 49259ea2d3..c082be41b6 100644 --- a/pom.xml +++ b/pom.xml @@ -24,7 +24,6 @@ opendaylight/model - opendaylight/commons/concepts opendaylight/commons/protocol-framework opendaylight/commons/checkstyle opendaylight/commons/opendaylight