-
-
Notifications
You must be signed in to change notification settings - Fork 4
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
34 changed files
with
784 additions
and
276 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
15 changes: 15 additions & 0 deletions
15
kala-base/src/main/java/kala/value/AbstractMutableValue.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
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 |
---|---|---|
@@ -1,8 +1,24 @@ | ||
/* | ||
* Copyright 2024 Glavo | ||
* | ||
* 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 | ||
* | ||
* 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 kala.value; | ||
|
||
import kala.Equatable; | ||
import kala.collection.base.AnyTraversable; | ||
import kala.value.primitive.PrimitiveValue; | ||
|
||
public interface AnyValue<T> extends AnyTraversable<T>, Equatable { | ||
public sealed interface AnyValue<T> extends AnyTraversable<T>, Equatable permits MutableAnyValue, Value, PrimitiveValue { | ||
T getValue(); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,57 @@ | ||
package kala.value; | ||
|
||
import java.io.Serializable; | ||
|
||
public final class CheckedVar<T> extends AbstractMutableValue<T> implements Cloneable, Serializable { | ||
private static final long serialVersionUID = 0L; | ||
|
||
private final Class<T> type; | ||
private T value; | ||
|
||
public CheckedVar(Class<T> type) { | ||
this.type = type; | ||
} | ||
|
||
public CheckedVar(Class<T> type, T value) { | ||
this.type = type; | ||
this.value = type.cast(value); | ||
} | ||
|
||
@Override | ||
public T get() { | ||
return value; | ||
} | ||
|
||
@Override | ||
public void set(T value) throws ClassCastException { | ||
this.value = type.cast(value); | ||
} | ||
|
||
@Override | ||
@SuppressWarnings("MethodDoesntCallSuperMethod") | ||
public CheckedVar<T> clone() { | ||
return new CheckedVar<>(type, value); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "CheckedVar[" + value + "]"; | ||
} | ||
} | ||
/* | ||
* Copyright 2024 Glavo | ||
* | ||
* 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 | ||
* | ||
* 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 kala.value; | ||
|
||
import java.io.Serial; | ||
import java.io.Serializable; | ||
|
||
public final class CheckedVar<T> extends AbstractMutableValue<T> implements Cloneable, Serializable { | ||
@Serial | ||
private static final long serialVersionUID = 0L; | ||
|
||
private final Class<T> type; | ||
private T value; | ||
|
||
public CheckedVar(Class<T> type) { | ||
this.type = type; | ||
} | ||
|
||
public CheckedVar(Class<T> type, T value) { | ||
this.type = type; | ||
this.value = type.cast(value); | ||
} | ||
|
||
@Override | ||
public T get() { | ||
return value; | ||
} | ||
|
||
@Override | ||
public void set(T value) throws ClassCastException { | ||
this.value = type.cast(value); | ||
} | ||
|
||
@Override | ||
@SuppressWarnings("MethodDoesntCallSuperMethod") | ||
public CheckedVar<T> clone() { | ||
return new CheckedVar<>(type, value); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "CheckedVar[" + value + "]"; | ||
} | ||
} |
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
17 changes: 17 additions & 0 deletions
17
kala-base/src/main/java/kala/value/DelegateMutableValue.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
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
Oops, something went wrong.