Major overhaul of entire project infrastructure.

Formatted source with Spring formatter. Fixed license headers and author tags.
This commit is contained in:
Oliver Gierke
2012-02-15 21:58:56 +01:00
parent 7a0b433e84
commit 7693b8ed51
51 changed files with 1388 additions and 1634 deletions

View File

@@ -1,68 +1,57 @@
/*
* Copyright 2008-2010 the original author or authors.
*
* Licensed 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
*
* Copyright 2012 the original author or authors.
*
* Licensed 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.
* 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.synyx.hera.metadata;
import org.synyx.hera.core.Plugin;
import org.synyx.hera.core.PluginRegistry;
/**
* Abstract base class for plugins based on {@code PluginMetadata}. Plugins
* based on this class can be selected from the {@code PluginRegistry} via an
* instance of {@code PluginMetadata}. Therefore you can regard this as a role
* model implementation of a base class for certain delimiter implmentations.
* Abstract base class for plugins based on {@link PluginMetadata}. Plugins based on this class can be selected from the
* {@link PluginRegistry} via an instance of {@link PluginMetadata}. Therefore you can regard this as a role model
* implementation of a base class for certain delimiter implmentations.
*
* @author Oliver Gierke - gierke@synyx.de
* @author Oliver Gierke
*/
public abstract class AbstractMetadataBasedPlugin implements
Plugin<PluginMetadata>, MetadataProvider {
public abstract class AbstractMetadataBasedPlugin implements Plugin<PluginMetadata>, MetadataProvider {
private PluginMetadata metadata;
private final PluginMetadata metadata;
/**
* Creates a new instance of {@code AbstractMetadataBasedPlugin}.
*
* @param name must not be {@literal null}.
* @param version must not be {@literal null}.
*/
public AbstractMetadataBasedPlugin(String name, String version) {
this.metadata = new SimplePluginMetadata(name, version);
}
/**
* Creates a new instance of {@code AbstractMetadataBasedPlugin}.
*
* @param name
* @param version
*/
public AbstractMetadataBasedPlugin(String name, String version) {
/*
* (non-Javadoc)
* @see org.synyx.hera.core.Plugin#supports(java.lang.Object)
*/
public boolean supports(PluginMetadata delimiter) {
return getMetadata().equals(delimiter);
}
this.metadata = new SimplePluginMetadata(name, version);
}
/*
* (non-Javadoc)
*
* @see com.synyx.minos.core.plugin.Plugin#supports(java.lang.Object)
*/
public boolean supports(PluginMetadata delimiter) {
return getMetadata().equals(delimiter);
}
/*
* (non-Javadoc)
*
* @see com.synyx.minos.core.plugin.MetadataProvider#getMetadata()
*/
public PluginMetadata getMetadata() {
return metadata;
}
/*
* (non-Javadoc)
* @see org.synyx.hera.metadata.MetadataProvider#getMetadata()
*/
public PluginMetadata getMetadata() {
return metadata;
}
}

View File

@@ -1,33 +1,31 @@
/*
* Copyright 2008-2010 the original author or authors.
*
* Licensed 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
*
* Copyright 2008-2012 the original author or authors.
*
* Licensed 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.
* 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.synyx.hera.metadata;
/**
* Interface for plugins providing metadata information. Usually the plugins
* will implement this interface themselves.
* Interface for plugins providing metadata information. Usually the plugins will implement this interface themselves.
*
* @author Oliver Gierke - gierke@synyx.de
* @author Oliver Gierke
*/
public interface MetadataProvider {
/**
* Returns the plugins metadata.
*
* @return the plugins metadata
*/
PluginMetadata getMetadata();
/**
* Returns the plugins metadata.
*
* @return the plugins metadata
*/
PluginMetadata getMetadata();
}

View File

@@ -1,17 +1,17 @@
/*
* Copyright 2008-2010 the original author or authors.
*
* Licensed 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
*
* Copyright 2008-2012 the original author or authors.
*
* Licensed 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.
* 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.synyx.hera.metadata;
@@ -19,24 +19,21 @@ package org.synyx.hera.metadata;
/**
* Basic interface to define a set of metadata information for plugins.
*
* @author Oliver Gierke - gierke@synyx.de
* @author Oliver Gierke
*/
public interface PluginMetadata {
/**
* Returns a unique plugin name. Plugins return a metadata implementation
* have to ensure uniqueness of this name.
*
* @return the name of the plugin
*/
String getName();
/**
* Returns a unique plugin name. Plugins return a metadata implementation have to ensure uniqueness of this name.
*
* @return the name of the plugin
*/
String getName();
/**
* Returns the plugin version. This allows rudimentary versioning
* possibilities.
*
* @return the version of the plugin
*/
String getVersion();
/**
* Returns the plugin version. This allows rudimentary versioning possibilities.
*
* @return the version of the plugin
*/
String getVersion();
}

View File

@@ -18,6 +18,7 @@ package org.synyx.hera.metadata;
import static org.springframework.util.ObjectUtils.*;
import org.springframework.util.Assert;
/**
* Value object style implementation of {@code PluginMetadata}.
@@ -26,90 +27,78 @@ import static org.springframework.util.ObjectUtils.*;
*/
public class SimplePluginMetadata implements PluginMetadata {
private String name;
private String version;
private final String name;
private final String version;
/**
* Creates a new instance of {@code SimplePluginMetadata}.
*
* @param name must not be {@literal null}.
* @param version must not be {@literal null}.
*/
public SimplePluginMetadata(String name, String version) {
/**
* Creates a new instance of {@code SimplePluginMetadata}.
*
* @param name
* @param version
*/
public SimplePluginMetadata(String name, String version) {
Assert.hasText(name, "Name must not be null or empty!");
Assert.hasText(version, "Version must not be null or empty!");
this.name = name;
this.version = version;
}
this.name = name;
this.version = version;
}
/*
* (non-Javadoc)
* @see org.synyx.hera.metadata.PluginMetadata#getName()
*/
public String getName() {
return name;
}
/*
* (non-Javadoc)
*
* @see com.synyx.minos.core.plugin.PluginMetadata#getName()
*/
public String getName() {
/*
* (non-Javadoc)
* @see org.synyx.hera.metadata.PluginMetadata#getVersion()
*/
public String getVersion() {
return version;
}
return name;
}
/*
* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
return String.format("%s:%s", getName(), getVersion());
}
/*
* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj) {
/*
* (non-Javadoc)
*
* @see com.synyx.minos.core.plugin.PluginMetadata#getVersion()
*/
public String getVersion() {
if (this == obj) {
return true;
}
return version;
}
if (!(obj instanceof PluginMetadata)) {
return false;
}
PluginMetadata that = (PluginMetadata) obj;
/*
* (non-Javadoc)
*
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
boolean sameName = nullSafeEquals(this.getName(), that.getName());
boolean sameVersion = nullSafeEquals(this.getName(), that.getName());
return String.format("%s:%s", getName(), getVersion());
}
return sameName && sameVersion;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof PluginMetadata)) {
return false;
}
PluginMetadata that = (PluginMetadata) obj;
boolean sameName = nullSafeEquals(this.getName(), that.getName());
boolean sameVersion = nullSafeEquals(this.getName(), that.getName());
return sameName && sameVersion;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
return nullSafeHashCode(name) + nullSafeHashCode(version);
}
/*
* (non-Javadoc)
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
return nullSafeHashCode(name) + nullSafeHashCode(version);
}
}