From cfc6217c97697be413e87507290bd991f88ce02d Mon Sep 17 00:00:00 2001 From: zhouxiang Date: Tue, 10 May 2022 16:11:28 +0800 Subject: [PATCH] [ISSUE #3949] Remove unused class --- .../rocketmq/common/TopicAttributes.java | 1 - .../attribute/AbstractRangeAttribute.java | 47 ----------------- .../common/attribute/IntRangeAttribute.java | 29 ----------- .../common/attribute/LongRangeAttribute.java | 23 ++++++-- .../common/constant/TopicMessageTypeName.java | 52 ------------------- 5 files changed, 19 insertions(+), 133 deletions(-) delete mode 100644 common/src/main/java/org/apache/rocketmq/common/attribute/AbstractRangeAttribute.java delete mode 100644 common/src/main/java/org/apache/rocketmq/common/attribute/IntRangeAttribute.java delete mode 100644 common/src/main/java/org/apache/rocketmq/common/constant/TopicMessageTypeName.java diff --git a/common/src/main/java/org/apache/rocketmq/common/TopicAttributes.java b/common/src/main/java/org/apache/rocketmq/common/TopicAttributes.java index 8c7dd0ead3..5ac1712985 100644 --- a/common/src/main/java/org/apache/rocketmq/common/TopicAttributes.java +++ b/common/src/main/java/org/apache/rocketmq/common/TopicAttributes.java @@ -42,6 +42,5 @@ public class TopicAttributes { static { ALL = new HashMap<>(); ALL.put(QUEUE_TYPE_ATTRIBUTE.getName(), QUEUE_TYPE_ATTRIBUTE); - ALL.put(TOPIC_MESSAGE_TYPE_ATTRIBUTE.getName(), TOPIC_MESSAGE_TYPE_ATTRIBUTE); } } diff --git a/common/src/main/java/org/apache/rocketmq/common/attribute/AbstractRangeAttribute.java b/common/src/main/java/org/apache/rocketmq/common/attribute/AbstractRangeAttribute.java deleted file mode 100644 index 7b773884e0..0000000000 --- a/common/src/main/java/org/apache/rocketmq/common/attribute/AbstractRangeAttribute.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ -package org.apache.rocketmq.common.attribute; - -import static java.lang.String.format; - -public abstract class AbstractRangeAttribute> extends Attribute { - - protected final T min; - protected final T max; - protected final T defaultValue; - - public AbstractRangeAttribute(String name, boolean changeable, T min, T max, T defaultValue) { - super(name, changeable); - this.min = min; - this.max = max; - this.defaultValue = defaultValue; - } - - protected abstract T parse(String value); - - @Override - public void verify(String value) { - T l = parse(value); - if (l.compareTo(min) < 0 || l.compareTo(max) > 0) { - throw new RuntimeException(format("value is not in range(%s, %s)", min, max)); - } - } - - public T getDefaultValue() { - return defaultValue; - } -} diff --git a/common/src/main/java/org/apache/rocketmq/common/attribute/IntRangeAttribute.java b/common/src/main/java/org/apache/rocketmq/common/attribute/IntRangeAttribute.java deleted file mode 100644 index d55a3124ff..0000000000 --- a/common/src/main/java/org/apache/rocketmq/common/attribute/IntRangeAttribute.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ -package org.apache.rocketmq.common.attribute; - -public class IntRangeAttribute extends AbstractRangeAttribute { - - public IntRangeAttribute(String name, boolean changeable, int min, int max, int defaultValue) { - super(name, changeable, min, max, defaultValue); - } - - @Override - protected Integer parse(String value) { - return Integer.parseInt(value); - } -} diff --git a/common/src/main/java/org/apache/rocketmq/common/attribute/LongRangeAttribute.java b/common/src/main/java/org/apache/rocketmq/common/attribute/LongRangeAttribute.java index f4ccbc561e..eeeda72153 100644 --- a/common/src/main/java/org/apache/rocketmq/common/attribute/LongRangeAttribute.java +++ b/common/src/main/java/org/apache/rocketmq/common/attribute/LongRangeAttribute.java @@ -16,14 +16,29 @@ */ package org.apache.rocketmq.common.attribute; -public class LongRangeAttribute extends AbstractRangeAttribute { +import static java.lang.String.format; + +public class LongRangeAttribute extends Attribute { + private final long min; + private final long max; + private final long defaultValue; public LongRangeAttribute(String name, boolean changeable, long min, long max, long defaultValue) { - super(name, changeable, min, max, defaultValue); + super(name, changeable); + this.min = min; + this.max = max; + this.defaultValue = defaultValue; } @Override - protected Long parse(String value) { - return Long.parseLong(value); + public void verify(String value) { + long l = Long.parseLong(value); + if (l < min || l > max) { + throw new RuntimeException(format("value is not in range(%d, %d)", min, max)); + } + } + + public long getDefaultValue() { + return defaultValue; } } diff --git a/common/src/main/java/org/apache/rocketmq/common/constant/TopicMessageTypeName.java b/common/src/main/java/org/apache/rocketmq/common/constant/TopicMessageTypeName.java deleted file mode 100644 index 0050acee0f..0000000000 --- a/common/src/main/java/org/apache/rocketmq/common/constant/TopicMessageTypeName.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ -package org.apache.rocketmq.common.constant; - -public class TopicMessageTypeName { - public static final int INDEX_TRANSACTION = 4; - public static final int INDEX_DELAY = 3; - public static final int INDEX_FIFO = 2; - public static final int INDEX_NORMAL = 1; - - public static final int TRANSACTION = 0x1 << INDEX_TRANSACTION; - public static final int DELAY = 0x1 << INDEX_DELAY; - public static final int FIFO = 0x1 << INDEX_FIFO; - public static final int NORMAL = 0x1 << INDEX_NORMAL; - public static final int UNSPECIFIED = 0; - - public static final int ALL = NORMAL | FIFO | DELAY | TRANSACTION; - - public static boolean isUnspecified(final int type) { - return type == UNSPECIFIED; - } - - public static boolean isNormal(final int type) { - return (type & NORMAL) == NORMAL; - } - - public static boolean isFifo(final int type) { - return (type & FIFO) == FIFO; - } - - public static boolean isDelay(final int type) { - return (type & DELAY) == DELAY; - } - - public static boolean isTransaction(final int type) { - return (type & TRANSACTION) == TRANSACTION; - } -}