-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
380 additions
and
216 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 4 additions & 5 deletions
9
...ncept-plugin-core/src/main/java/com/github/linyuzai/plugin/core/handle/PluginHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 0 additions & 25 deletions
25
...re/src/main/java/com/github/linyuzai/plugin/core/handle/PropertyPluginHandlerFactory.java
This file was deleted.
Oops, something went wrong.
22 changes: 22 additions & 0 deletions
22
.../java/com/github/linyuzai/plugin/core/handle/StringArrayPropertyPluginHandlerFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.github.linyuzai.plugin.core.handle; | ||
|
||
import com.github.linyuzai.plugin.core.metadata.PluginMetadata; | ||
import com.github.linyuzai.plugin.core.context.PluginContext; | ||
import com.github.linyuzai.plugin.core.metadata.property.MetadataProperty; | ||
|
||
public abstract class StringArrayPropertyPluginHandlerFactory implements PluginHandlerFactory { | ||
|
||
@Override | ||
public PluginHandler create(PluginContext context) { | ||
PluginMetadata metadata = context.getPlugin().getMetadata(); | ||
String[] array = metadata.property(getProperty()); | ||
if (array.length == 0) { | ||
return null; | ||
} | ||
return doCreate(array); | ||
} | ||
|
||
public abstract MetadataProperty<String[]> getProperty(); | ||
|
||
public abstract PluginHandler doCreate(String[] array); | ||
} |
10 changes: 6 additions & 4 deletions
10
...-core/src/main/java/com/github/linyuzai/plugin/core/handle/filter/EntryFilterFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...pt-plugin-core/src/main/java/com/github/linyuzai/plugin/core/metadata/PluginMetadata.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.github.linyuzai.plugin.core.metadata; | ||
|
||
import com.github.linyuzai.plugin.core.metadata.property.MetadataProperty; | ||
|
||
import java.util.Set; | ||
|
||
public interface PluginMetadata { | ||
|
||
String NAME = "plugin.properties"; | ||
|
||
default <T> T property(MetadataProperty<T> mp) { | ||
String value = get(mp.getName()); | ||
return mp.getValue(value); | ||
} | ||
|
||
default <T> T property(MetadataProperty<T> mp, String defaultValue) { | ||
String value = get(mp.getName(), defaultValue); | ||
return mp.getValue(value); | ||
} | ||
|
||
String get(String name); | ||
|
||
String get(String name, String defaultValue); | ||
|
||
Set<String> names(); | ||
|
||
<T> T bind(String name, Class<T> type); | ||
|
||
boolean isEmpty(); | ||
} |
39 changes: 39 additions & 0 deletions
39
...core/src/main/java/com/github/linyuzai/plugin/core/metadata/PropertiesPluginMetadata.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.github.linyuzai.plugin.core.metadata; | ||
|
||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
import java.util.Properties; | ||
import java.util.Set; | ||
|
||
@Getter | ||
@RequiredArgsConstructor | ||
public class PropertiesPluginMetadata implements PluginMetadata { | ||
|
||
private final Properties properties; | ||
|
||
@Override | ||
public String get(String name) { | ||
return properties.getProperty(name); | ||
} | ||
|
||
@Override | ||
public String get(String name, String defaultValue) { | ||
return properties.getProperty(name, defaultValue); | ||
} | ||
|
||
@Override | ||
public Set<String> names() { | ||
return properties.stringPropertyNames(); | ||
} | ||
|
||
@Override | ||
public <T> T bind(String name, Class<T> type) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public boolean isEmpty() { | ||
return properties.isEmpty(); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...main/java/com/github/linyuzai/plugin/core/metadata/property/AbstractMetadataProperty.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.github.linyuzai.plugin.core.metadata.property; | ||
|
||
import lombok.Getter; | ||
|
||
@Getter | ||
public abstract class AbstractMetadataProperty<T> implements MetadataProperty<T> { | ||
|
||
private final String name; | ||
|
||
public AbstractMetadataProperty(String name, MetadataProperty<?> prefix) { | ||
if (prefix == null) { | ||
this.name = name; | ||
} else { | ||
this.name = prefix.getName() + "." + name; | ||
} | ||
} | ||
} |
Oops, something went wrong.