Skip to content

Commit

Permalink
Merge pull request #394 from KamToHung/master
Browse files Browse the repository at this point in the history
optimize enum related
  • Loading branch information
KamToHung committed Jan 24, 2024
2 parents 9e75364 + bd5e46b commit 9669ec6
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package org.dromara.dynamictp.common.em;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
Expand All @@ -26,6 +27,7 @@
* @since 1.0.0
**/
@Getter
@AllArgsConstructor
public enum ConfigFileTypeEnum {

/**
Expand All @@ -40,10 +42,6 @@ public enum ConfigFileTypeEnum {

private final String value;

ConfigFileTypeEnum(String value) {
this.value = value;
}

public static ConfigFileTypeEnum of(String value) {
for (ConfigFileTypeEnum typeEnum : ConfigFileTypeEnum.values()) {
if (typeEnum.value.equals(value)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package org.dromara.dynamictp.common.em;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
Expand All @@ -26,6 +27,7 @@
* @since 1.0.0
**/
@Getter
@AllArgsConstructor
public enum NotifyItemEnum {

/**
Expand Down Expand Up @@ -63,11 +65,6 @@ public enum NotifyItemEnum {

private final String unit;

NotifyItemEnum(String value, String unit) {
this.value = value;
this.unit = unit;
}

public static NotifyItemEnum of(String value) {
for (NotifyItemEnum notifyItem : NotifyItemEnum.values()) {
if (notifyItem.value.equals(value)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package org.dromara.dynamictp.common.em;

import lombok.AllArgsConstructor;
import org.dromara.dynamictp.common.ex.DtpException;
import org.dromara.dynamictp.common.queue.MemorySafeLinkedBlockingQueue;
import org.dromara.dynamictp.common.queue.VariableLinkedBlockingQueue;
Expand All @@ -43,6 +44,7 @@
**/
@Slf4j
@Getter
@AllArgsConstructor
public enum QueueTypeEnum {

/**
Expand All @@ -66,13 +68,9 @@ public enum QueueTypeEnum {

MEMORY_SAFE_LINKED_BLOCKING_QUEUE(9, "MemorySafeLinkedBlockingQueue");

private final Integer code;
private final String name;
private final int code;

QueueTypeEnum(Integer code, String name) {
this.code = code;
this.name = name;
}
private final String name;

public static BlockingQueue<Runnable> buildLbq(String name, int capacity) {
return buildLbq(name, capacity, false, 256);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package org.dromara.dynamictp.common.em;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;

Expand All @@ -28,6 +29,7 @@
**/
@Slf4j
@Getter
@AllArgsConstructor
public enum RejectedTypeEnum {

/**
Expand All @@ -43,7 +45,4 @@ public enum RejectedTypeEnum {

private final String name;

RejectedTypeEnum(String name) {
this.name = name;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,17 @@

package org.dromara.dynamictp.core.aware;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
* AwareType Enum
*
* @author kyao
* @since 1.1.4
*/
@Getter
@AllArgsConstructor
public enum AwareTypeEnum {

/**
Expand All @@ -44,16 +49,4 @@ public enum AwareTypeEnum {

private final String name;

AwareTypeEnum(int order, String name) {
this.order = order;
this.name = name;
}

public int getOrder() {
return order;
}

public String getName() {
return name;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package org.dromara.dynamictp.core.executor;

import lombok.AllArgsConstructor;
import org.dromara.dynamictp.core.executor.eager.EagerDtpExecutor;
import lombok.Getter;
import org.dromara.dynamictp.core.executor.priority.PriorityDtpExecutor;
Expand All @@ -28,6 +29,7 @@
* @since 1.0.4
**/
@Getter
@AllArgsConstructor
public enum ExecutorType {

/**
Expand Down Expand Up @@ -59,11 +61,6 @@ public enum ExecutorType {

private final Class<?> clazz;

ExecutorType(String name, Class<?> clazz) {
this.name = name;
this.clazz = clazz;
}

public static Class<?> getClass(String name) {
for (ExecutorType type : ExecutorType.values()) {
if (type.name.equals(name)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package org.dromara.dynamictp.extension.limiter.redis.em;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
Expand All @@ -26,6 +27,7 @@
* @since 1.0.8
**/
@Getter
@AllArgsConstructor
public enum RateLimitEnum {

/**
Expand All @@ -37,16 +39,4 @@ public enum RateLimitEnum {

private final String scriptName;

RateLimitEnum(final String keyName, final String scriptName) {
this.keyName = keyName;
this.scriptName = scriptName;
}

public String getKeyName() {
return this.keyName;
}

public String getScriptName() {
return this.scriptName;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package org.dromara.dynamictp.starter.adapter.webserver.undertow;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
Expand All @@ -26,6 +27,7 @@
* @since 1.1.3
*/
@Getter
@AllArgsConstructor
public enum UndertowTaskPoolEnum {

/**
Expand All @@ -46,14 +48,10 @@ public enum UndertowTaskPoolEnum {
/**
* ExecutorServiceTaskPool
*/
EXECUTOR_SERVICE_TASK_POOL("ExecutorServiceTaskPool", "delegate"),;
EXECUTOR_SERVICE_TASK_POOL("ExecutorServiceTaskPool", "delegate");

private final String className;

private final String internalExecutor;

UndertowTaskPoolEnum(String className, String internalExecutor) {
this.className = className;
this.internalExecutor = internalExecutor;
}
}

0 comments on commit 9669ec6

Please sign in to comment.