GH-104 - Remove metadata module.
This commit is contained in:
@@ -1,39 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>spring-plugin-metadata</artifactId>
|
||||
|
||||
<name>Spring Plugin - Metadata Extension</name>
|
||||
<description>Extension package for metadata based plugins</description>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.plugin</groupId>
|
||||
<artifactId>spring-plugin</artifactId>
|
||||
<version>4.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<java-module-name>spring.plugin.metadata</java-module-name>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>../src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
<targetPath>META-INF</targetPath>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>spring-plugin-core</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -1,57 +0,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
|
||||
*
|
||||
* https://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.springframework.plugin.metadata;
|
||||
|
||||
import org.springframework.plugin.core.Plugin;
|
||||
import org.springframework.plugin.core.PluginRegistry;
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
public abstract class AbstractMetadataBasedPlugin implements Plugin<PluginMetadata>, MetadataProvider {
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.plugin.core.Plugin#supports(java.lang.Object)
|
||||
*/
|
||||
public boolean supports(PluginMetadata delimiter) {
|
||||
return getMetadata().equals(delimiter);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.plugin.metadata.MetadataProvider#getMetadata()
|
||||
*/
|
||||
public PluginMetadata getMetadata() {
|
||||
return metadata;
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,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
|
||||
*
|
||||
* https://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.springframework.plugin.metadata;
|
||||
|
||||
/**
|
||||
* Interface for plugins providing metadata information. Usually the plugins will implement this interface themselves.
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
public interface MetadataProvider {
|
||||
|
||||
/**
|
||||
* Returns the plugins metadata.
|
||||
*
|
||||
* @return the plugins metadata
|
||||
*/
|
||||
PluginMetadata getMetadata();
|
||||
}
|
||||
@@ -1,39 +0,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
|
||||
*
|
||||
* https://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.springframework.plugin.metadata;
|
||||
|
||||
/**
|
||||
* Basic interface to define a set of metadata information for plugins.
|
||||
*
|
||||
* @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 the plugin version. This allows rudimentary versioning possibilities.
|
||||
*
|
||||
* @return the version of the plugin
|
||||
*/
|
||||
String getVersion();
|
||||
}
|
||||
@@ -1,104 +0,0 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* https://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.springframework.plugin.metadata;
|
||||
|
||||
import static org.springframework.util.ObjectUtils.*;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Value object style implementation of {@code PluginMetadata}.
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
public class SimplePluginMetadata implements PluginMetadata {
|
||||
|
||||
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) {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.plugin.metadata.PluginMetadata#getName()
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.plugin.metadata.PluginMetadata#getVersion()
|
||||
*/
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
/*
|
||||
* (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) {
|
||||
|
||||
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.getVersion(), that.getVersion());
|
||||
|
||||
return sameName && sameVersion;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see java.lang.Object#hashCode()
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return nullSafeHashCode(name) + nullSafeHashCode(version);
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
/*
|
||||
* Copyright 2015-2021 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
|
||||
*
|
||||
* https://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.springframework.plugin.metadata;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link SimplePluginMetadata}.
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
class SimplePluginMetadataUnitTest {
|
||||
|
||||
/**
|
||||
* @see #11
|
||||
*/
|
||||
@Test
|
||||
void equalsIsWorkingCorrectly() {
|
||||
|
||||
SimplePluginMetadata nameOneOh = new SimplePluginMetadata("Name", "1.0");
|
||||
SimplePluginMetadata sameNameOneOh = new SimplePluginMetadata("Name", "1.0");
|
||||
SimplePluginMetadata nameTwoOh = new SimplePluginMetadata("Name", "2.0");
|
||||
SimplePluginMetadata anotherNameOneOh = new SimplePluginMetadata("AnotherName", "1.0");
|
||||
|
||||
assertThat(nameOneOh).isEqualTo(nameOneOh);
|
||||
assertThat(nameOneOh).isEqualTo(sameNameOneOh);
|
||||
assertThat(sameNameOneOh).isEqualTo(nameOneOh);
|
||||
|
||||
assertThat(nameOneOh).isNotEqualTo(nameTwoOh);
|
||||
assertThat(nameTwoOh).isNotEqualTo(nameOneOh);
|
||||
|
||||
assertThat(nameOneOh).isNotEqualTo(anotherNameOneOh);
|
||||
assertThat(anotherNameOneOh).isNotEqualTo(nameOneOh);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user