mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 03:31:15 +03:00
[DOC] Документация к основным классам LauncherCore
This commit is contained in:
parent
79a2881089
commit
c5d09557da
8 changed files with 62 additions and 1 deletions
|
@ -4,6 +4,14 @@
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allows calling commands using the config command
|
||||||
|
*/
|
||||||
public interface Reconfigurable {
|
public interface Reconfigurable {
|
||||||
|
/**
|
||||||
|
* Gets a list of commands available for this object.
|
||||||
|
* @return Key - Command Name
|
||||||
|
* Value is a command object
|
||||||
|
*/
|
||||||
Map<String, Command> getCommands();
|
Map<String, Command> getCommands();
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,10 @@
|
||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This annotation implies that method/field/class should not be renamed or obfuscated
|
||||||
|
*/
|
||||||
@Retention(RetentionPolicy.CLASS)
|
@Retention(RetentionPolicy.CLASS)
|
||||||
@Target({ElementType.TYPE, ElementType.FIELD, ElementType.CONSTRUCTOR, ElementType.METHOD})
|
@Target({ElementType.TYPE, ElementType.FIELD, ElementType.CONSTRUCTOR, ElementType.METHOD})
|
||||||
public @interface LauncherAPI {
|
public @interface LauncherAPI {
|
||||||
/* This annotation implies that method/field/class should not be renamed or obfuscated */
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,10 @@
|
||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This annotation implies that method/field/class should not be renamed or obfuscated
|
||||||
|
* It is used for classes and fields serializable with the help of GSON to save the field name during transmission over the network.
|
||||||
|
*/
|
||||||
@Retention(RetentionPolicy.CLASS)
|
@Retention(RetentionPolicy.CLASS)
|
||||||
@Target({ElementType.TYPE, ElementType.FIELD, ElementType.CONSTRUCTOR, ElementType.METHOD})
|
@Target({ElementType.TYPE, ElementType.FIELD, ElementType.CONSTRUCTOR, ElementType.METHOD})
|
||||||
public @interface LauncherNetworkAPI {
|
public @interface LauncherNetworkAPI {
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
package pro.gravit.launcher;
|
package pro.gravit.launcher;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines whether this object requires periodic garbage collection by the gc command
|
||||||
|
* This interface has nothing to do with java garbage collection.
|
||||||
|
*/
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
public interface NeedGarbageCollection {
|
public interface NeedGarbageCollection {
|
||||||
void garbageCollection();
|
void garbageCollection();
|
||||||
|
|
|
@ -8,6 +8,15 @@ public class BiHookSet<V, R> {
|
||||||
|
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
public interface Hook<V, R> {
|
public interface Hook<V, R> {
|
||||||
|
/**
|
||||||
|
* @param context custom param
|
||||||
|
* @param object custom param
|
||||||
|
* @return
|
||||||
|
* True if you need to interrupt hook processing
|
||||||
|
* False to continue processing hook
|
||||||
|
* @throws HookException
|
||||||
|
* The hook may return the error text throwing this exception
|
||||||
|
*/
|
||||||
boolean hook(V object, R context) throws HookException;
|
boolean hook(V object, R context) throws HookException;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,6 +28,15 @@ public boolean unregisterHook(Hook<V, R> hook) {
|
||||||
return list.remove(hook);
|
return list.remove(hook);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param context custom param
|
||||||
|
* @param object custom param
|
||||||
|
* @return
|
||||||
|
* True if hook to interrupt processing
|
||||||
|
* False to continue
|
||||||
|
* @throws HookException
|
||||||
|
* The hook may return the error text throwing this exception
|
||||||
|
*/
|
||||||
public boolean hook(V context, R object) throws HookException {
|
public boolean hook(V context, R object) throws HookException {
|
||||||
for (Hook<V, R> hook : list) {
|
for (Hook<V, R> hook : list) {
|
||||||
if (hook.hook(context, object)) return true;
|
if (hook.hook(context, object)) return true;
|
||||||
|
|
|
@ -8,6 +8,14 @@ public class HookSet<R> {
|
||||||
|
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
public interface Hook<R> {
|
public interface Hook<R> {
|
||||||
|
/**
|
||||||
|
* @param context custom param
|
||||||
|
* @return
|
||||||
|
* True if you need to interrupt hook processing
|
||||||
|
* False to continue processing hook
|
||||||
|
* @throws HookException
|
||||||
|
* The hook may return the error text throwing this exception
|
||||||
|
*/
|
||||||
boolean hook(R context) throws HookException;
|
boolean hook(R context) throws HookException;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,6 +27,14 @@ public boolean unregisterHook(Hook<R> hook) {
|
||||||
return list.remove(hook);
|
return list.remove(hook);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param context custom param
|
||||||
|
* @return
|
||||||
|
* True if hook to interrupt processing
|
||||||
|
* False to continue
|
||||||
|
* @throws HookException
|
||||||
|
* The hook may return the error text throwing this exception
|
||||||
|
*/
|
||||||
public boolean hook(R context) throws HookException {
|
public boolean hook(R context) throws HookException {
|
||||||
for (Hook<R> hook : list) {
|
for (Hook<R> hook : list) {
|
||||||
if (hook.hook(context)) return true;
|
if (hook.hook(context)) return true;
|
||||||
|
|
|
@ -6,6 +6,10 @@
|
||||||
|
|
||||||
import pro.gravit.utils.helper.VerifyHelper;
|
import pro.gravit.utils.helper.VerifyHelper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The relationship between classes of an interface or abstract class and names when they are serialized
|
||||||
|
* @param <R> Class or interface type
|
||||||
|
*/
|
||||||
public class ProviderMap<R> {
|
public class ProviderMap<R> {
|
||||||
protected final Map<String, Class<? extends R>> PROVIDERS = new ConcurrentHashMap<>(4);
|
protected final Map<String, Class<? extends R>> PROVIDERS = new ConcurrentHashMap<>(4);
|
||||||
protected final String name;
|
protected final String name;
|
||||||
|
|
|
@ -13,6 +13,11 @@
|
||||||
|
|
||||||
import pro.gravit.utils.helper.LogHelper;
|
import pro.gravit.utils.helper.LogHelper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An adapter that uses {@link ProviderMap} to serialize and deserialize a group of similar objects
|
||||||
|
* @param <R> Class or interface type
|
||||||
|
* @see ProviderMap
|
||||||
|
*/
|
||||||
public class UniversalJsonAdapter<R> implements JsonSerializer<R>, JsonDeserializer<R> {
|
public class UniversalJsonAdapter<R> implements JsonSerializer<R>, JsonDeserializer<R> {
|
||||||
public final ProviderMap<R> providerMap;
|
public final ProviderMap<R> providerMap;
|
||||||
public final String name;
|
public final String name;
|
||||||
|
|
Loading…
Reference in a new issue