Compare commits
2 Commits
12596fd7f2
...
1725ce1a9c
Author | SHA1 | Date | |
---|---|---|---|
1725ce1a9c | |||
a96c90ec35 |
@ -17,6 +17,6 @@ import java.lang.annotation.Target;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
public @interface AdditionalClassForDotNetSimulation {
|
||||
public @interface AdditionalClassForDotNetEmulation {
|
||||
String note() default "";
|
||||
}
|
@ -4,7 +4,7 @@
|
||||
*/
|
||||
package com.openeggbert.jdotnet.JDotNet.CSharpKeyWords;
|
||||
|
||||
import com.openeggbert.jdotnet.JDotNet.AdditionalClassForDotNetSimulation;
|
||||
import com.openeggbert.jdotnet.JDotNet.AdditionalClassForDotNetEmulation;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
@ -18,7 +18,7 @@ import java.lang.annotation.Target;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@AdditionalClassForDotNetSimulation
|
||||
@AdditionalClassForDotNetEmulation
|
||||
public @interface const_ {
|
||||
String description() default "";
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
*/
|
||||
package com.openeggbert.jdotnet.JDotNet.CSharpKeyWords;
|
||||
|
||||
import com.openeggbert.jdotnet.JDotNet.AdditionalClassForDotNetSimulation;
|
||||
import com.openeggbert.jdotnet.JDotNet.AdditionalClassForDotNetEmulation;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
@ -18,7 +18,7 @@ import java.lang.annotation.Target;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD, ElementType.CONSTRUCTOR})
|
||||
@AdditionalClassForDotNetSimulation
|
||||
public @interface internal {
|
||||
@AdditionalClassForDotNetEmulation
|
||||
public @interface internal_ {
|
||||
String description() default "";
|
||||
}
|
@ -4,7 +4,7 @@
|
||||
*/
|
||||
package com.openeggbert.jdotnet.JDotNet.CSharpKeyWords;
|
||||
|
||||
import com.openeggbert.jdotnet.JDotNet.AdditionalClassForDotNetSimulation;
|
||||
import com.openeggbert.jdotnet.JDotNet.AdditionalClassForDotNetEmulation;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
@ -18,7 +18,7 @@ import java.lang.annotation.Target;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
@AdditionalClassForDotNetSimulation
|
||||
public @interface namespace {
|
||||
@AdditionalClassForDotNetEmulation
|
||||
public @interface namespace_ {
|
||||
String name();
|
||||
}
|
@ -4,7 +4,7 @@
|
||||
*/
|
||||
package com.openeggbert.jdotnet.JDotNet.CSharpKeyWords;
|
||||
|
||||
import com.openeggbert.jdotnet.JDotNet.AdditionalClassForDotNetSimulation;
|
||||
import com.openeggbert.jdotnet.JDotNet.AdditionalClassForDotNetEmulation;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
@ -18,7 +18,7 @@ import java.lang.annotation.Target;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.PARAMETER)
|
||||
@AdditionalClassForDotNetSimulation
|
||||
public @interface nullable {
|
||||
@AdditionalClassForDotNetEmulation
|
||||
public @interface nullable_ {
|
||||
String description() default "";
|
||||
}
|
@ -4,7 +4,7 @@
|
||||
*/
|
||||
package com.openeggbert.jdotnet.JDotNet.CSharpKeyWords;
|
||||
|
||||
import com.openeggbert.jdotnet.JDotNet.AdditionalClassForDotNetSimulation;
|
||||
import com.openeggbert.jdotnet.JDotNet.AdditionalClassForDotNetEmulation;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
@ -18,7 +18,7 @@ import java.lang.annotation.Target;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.PARAMETER)
|
||||
@AdditionalClassForDotNetSimulation
|
||||
public @interface out {
|
||||
@AdditionalClassForDotNetEmulation
|
||||
public @interface out_ {
|
||||
String description() default "";
|
||||
}
|
@ -4,7 +4,7 @@
|
||||
*/
|
||||
package com.openeggbert.jdotnet.JDotNet.CSharpKeyWords;
|
||||
|
||||
import com.openeggbert.jdotnet.JDotNet.AdditionalClassForDotNetSimulation;
|
||||
import com.openeggbert.jdotnet.JDotNet.AdditionalClassForDotNetEmulation;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
@ -18,7 +18,7 @@ import java.lang.annotation.Target;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.TYPE_USE, ElementType.FIELD})
|
||||
@AdditionalClassForDotNetSimulation
|
||||
public @interface readonly {
|
||||
@AdditionalClassForDotNetEmulation
|
||||
public @interface readonly_ {
|
||||
String description() default "";
|
||||
}
|
@ -4,7 +4,7 @@
|
||||
*/
|
||||
package com.openeggbert.jdotnet.JDotNet.CSharpKeyWords;
|
||||
|
||||
import com.openeggbert.jdotnet.JDotNet.AdditionalClassForDotNetSimulation;
|
||||
import com.openeggbert.jdotnet.JDotNet.AdditionalClassForDotNetEmulation;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
@ -18,7 +18,7 @@ import java.lang.annotation.Target;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.PARAMETER)
|
||||
@AdditionalClassForDotNetSimulation
|
||||
public @interface ref {
|
||||
@AdditionalClassForDotNetEmulation
|
||||
public @interface ref_ {
|
||||
String description() default "";
|
||||
}
|
@ -4,7 +4,7 @@
|
||||
*/
|
||||
package com.openeggbert.jdotnet.JDotNet.CSharpKeyWords;
|
||||
|
||||
import com.openeggbert.jdotnet.JDotNet.AdditionalClassForDotNetSimulation;
|
||||
import com.openeggbert.jdotnet.JDotNet.AdditionalClassForDotNetEmulation;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
@ -18,7 +18,7 @@ import java.lang.annotation.Target;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
@AdditionalClassForDotNetSimulation
|
||||
@AdditionalClassForDotNetEmulation
|
||||
public @interface static_ {
|
||||
String description() default "";
|
||||
}
|
||||
|
@ -4,14 +4,14 @@
|
||||
*/
|
||||
package com.openeggbert.jdotnet.JDotNet.CSharpKeyWords;
|
||||
|
||||
import com.openeggbert.jdotnet.JDotNet.AdditionalClassForDotNetSimulation;
|
||||
import com.openeggbert.jdotnet.JDotNet.AdditionalClassForDotNetEmulation;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author robertvokac
|
||||
*/
|
||||
|
||||
@AdditionalClassForDotNetSimulation
|
||||
@AdditionalClassForDotNetEmulation
|
||||
public abstract class struct<T> {
|
||||
public abstract T copy();
|
||||
/**
|
||||
|
@ -0,0 +1,32 @@
|
||||
package com.openeggbert.jdotnet.JDotNet.Properties;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* An abstract base class for implementing property-like behavior.
|
||||
*
|
||||
* This class provides a protected field "value" that can be used by subclasses
|
||||
* to manage the state of the property. The type of the property value is defined
|
||||
* by the generic type parameter <T>.
|
||||
*
|
||||
* Subclasses can provide specific implementations of read-only, write-only,
|
||||
* or read-write properties by exposing appropriate methods for access or modification
|
||||
* of the "value" field.
|
||||
*
|
||||
* @param <T> the type of the property's value
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public abstract class AbstractPropertyImpl<T> {
|
||||
/**
|
||||
* The value stored by the property.
|
||||
*
|
||||
* This field is protected to allow subclasses to directly manage
|
||||
* the property's value, while providing flexibility for implementing
|
||||
* specific behaviors such as read-only, write-only, or read-write access.
|
||||
*
|
||||
* @param <T> the type of the property's value
|
||||
*/
|
||||
protected T value;
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package com.openeggbert.jdotnet.JDotNet.Properties;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface IObservable<T> {
|
||||
void addObserver(Consumer<T> listener);
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package com.openeggbert.jdotnet.JDotNet.Properties;
|
||||
|
||||
/**
|
||||
* Represents a property that supports both read and write operations for a value of type T.
|
||||
*
|
||||
* The interface extends both IReadOnlyProperty and IWriteOnlyProperty, combining their
|
||||
* functionality to provide a complete property interface.
|
||||
*
|
||||
* @param <T> the type of the property's value
|
||||
*/
|
||||
public interface IProperty<T> extends IReadOnlyProperty<T>, IWriteOnlyProperty<T> {
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
package com.openeggbert.jdotnet.JDotNet.Properties;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface IPropertyChangeListener<T> {
|
||||
void propertyChanged(T oldValue, T newValue);
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package com.openeggbert.jdotnet.JDotNet.Properties;
|
||||
|
||||
/**
|
||||
* Represents a read-only property for a value of type T.
|
||||
*
|
||||
* This interface defines a single method to retrieve the property value,
|
||||
* ensuring that implementing classes provide read access while prohibiting
|
||||
* modification of the value it holds.
|
||||
*
|
||||
* @param <T> the type of the property's value
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface IReadOnlyProperty<T> {
|
||||
/**
|
||||
* Retrieves the value of the property.
|
||||
*
|
||||
* @return the current value of the property
|
||||
*/
|
||||
T get();
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package com.openeggbert.jdotnet.JDotNet.Properties;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface IVetoablePropertyChangeListener<T> {
|
||||
void vetoablePropertyChanged(T oldValue, T newValue) throws PropertyVetoException;
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package com.openeggbert.jdotnet.JDotNet.Properties;
|
||||
|
||||
/**
|
||||
* Represents a write-only property for a value of type T.
|
||||
*
|
||||
* This interface defines a single method to set the property value,
|
||||
* ensuring that implementing classes provide write access while prohibiting
|
||||
* retrieval of the value it holds.
|
||||
*
|
||||
* @param <T> the type of the property's value
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface IWriteOnlyProperty<T> {
|
||||
/**
|
||||
* Sets the value for the property.
|
||||
*
|
||||
* @param value the value to set for the property
|
||||
*/
|
||||
void set(T value);
|
||||
}
|
@ -0,0 +1,125 @@
|
||||
package com.openeggbert.jdotnet.JDotNet.Properties;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* A concrete implementation of the IProperty interface, providing both
|
||||
* read and write access to a property of type T.
|
||||
* <p>
|
||||
* This class extends AbstractPropertyImpl, leveraging its protected "value" field
|
||||
* to store the property's data, and implements the getter and setter methods
|
||||
* as specified by the IProperty interface.
|
||||
*
|
||||
* @param <T> the type of the property's value
|
||||
*/
|
||||
public class ObservablePropertyImpl<T> extends PropertyImpl<T> implements IObservable<T>{
|
||||
|
||||
private List<Consumer<T>> observers = new ArrayList<>();
|
||||
private final List<IPropertyChangeListener<T>> changeListeners = new ArrayList<>();
|
||||
private final List<IVetoablePropertyChangeListener<T>> vetoableChangeListeners = new ArrayList<>();
|
||||
|
||||
public ObservablePropertyImpl(IReadOnlyProperty<T> readOnlyPropertyIn, IWriteOnlyProperty<T> writeOnlyPropertyIn) {
|
||||
super(readOnlyPropertyIn, writeOnlyPropertyIn);
|
||||
}
|
||||
|
||||
public ObservablePropertyImpl(IReadOnlyProperty<T> readOnlyPropertyIn, IWriteOnlyProperty<T> writeOnlyPropertyIn, Validator<T> validator) {
|
||||
super(readOnlyPropertyIn, writeOnlyPropertyIn, validator);
|
||||
}
|
||||
public ObservablePropertyImpl(T initialValue) {
|
||||
super(initialValue);
|
||||
}
|
||||
public ObservablePropertyImpl(T initialValue, Validator<T> validator) {
|
||||
super(initialValue, validator);
|
||||
}
|
||||
@Override
|
||||
public void set(T valueIn) {
|
||||
T oldValue = this.get();
|
||||
|
||||
boolean vetoed = false;
|
||||
if(!vetoableChangeListeners.isEmpty()) {
|
||||
vetoed = notifyVetoableChangeListeners(oldValue, valueIn);
|
||||
}
|
||||
if(vetoed) {
|
||||
//nothing to do
|
||||
return;
|
||||
}
|
||||
super.set(valueIn);
|
||||
if(!observers.isEmpty()) {
|
||||
notifyListeners(valueIn);
|
||||
}
|
||||
if(!changeListeners.isEmpty()) {
|
||||
notifyChangeListeners(oldValue, valueIn);
|
||||
}
|
||||
}
|
||||
|
||||
private void notifyListeners(T value) {
|
||||
for (Consumer<T> listener : observers) {
|
||||
listener.accept(value);
|
||||
}
|
||||
}
|
||||
private void notifyChangeListeners(T oldValue, T newValue) {
|
||||
for (IPropertyChangeListener<T> listener : changeListeners) {
|
||||
listener.propertyChanged(oldValue, newValue);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notifies all registered vetoable change listeners of a potential change
|
||||
* from the old value to the new value. If any listener vetoes the change by
|
||||
* throwing a {@code PropertyVetoException}, the method stops further notifications
|
||||
* and returns {@code true}.
|
||||
*
|
||||
* @param oldValue the previous value before the change
|
||||
* @param newValue the proposed new value
|
||||
* @return {@code true} if the change was vetoed by any listener; {@code false} otherwise
|
||||
*/
|
||||
private boolean notifyVetoableChangeListeners(T oldValue, T newValue) {
|
||||
for (IVetoablePropertyChangeListener<T> listener : vetoableChangeListeners) {
|
||||
try {
|
||||
listener.vetoablePropertyChanged(oldValue, newValue);
|
||||
} catch (PropertyVetoException e) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public void addChangeListener(IPropertyChangeListener<T> changeListener) {
|
||||
changeListeners.add(changeListener);
|
||||
}
|
||||
|
||||
public void removeChangeListener(IPropertyChangeListener<T> changeListener) {
|
||||
changeListeners.remove(changeListener);
|
||||
}
|
||||
public void addVetoableChangeListener(IVetoablePropertyChangeListener<T> changeListener) {
|
||||
vetoableChangeListeners.add(changeListener);
|
||||
}
|
||||
|
||||
public void removeVetoableChangeListener(IVetoablePropertyChangeListener<T> vetoablePropertyChangeListener) {
|
||||
vetoableChangeListeners.remove(vetoablePropertyChangeListener);
|
||||
}
|
||||
|
||||
|
||||
public void addObserver(Consumer<T> listener) {
|
||||
observers.add(listener);
|
||||
}
|
||||
|
||||
public void removeObserver(Consumer<T> listener) {
|
||||
observers.remove(listener);
|
||||
}
|
||||
|
||||
public boolean hasListeners() {
|
||||
return !observers.isEmpty() || !changeListeners.isEmpty() || !vetoableChangeListeners.isEmpty();
|
||||
}
|
||||
public boolean hasObservers() {
|
||||
return !observers.isEmpty();
|
||||
}
|
||||
public boolean hasChangeListeners() {
|
||||
return !changeListeners.isEmpty();
|
||||
}
|
||||
public boolean hasVetoableChangeListeners() {
|
||||
return !vetoableChangeListeners.isEmpty();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
package com.openeggbert.jdotnet.JDotNet.Properties;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* A concrete implementation of the IProperty interface, providing both
|
||||
* read and write access to a property of type T.
|
||||
* <p>
|
||||
* This class extends AbstractPropertyImpl, leveraging its protected "value" field
|
||||
* to store the property's data, and implements the getter and setter methods
|
||||
* as specified by the IProperty interface.
|
||||
*
|
||||
* @param <T> the type of the property's value
|
||||
*/
|
||||
public class PropertyImpl<T> extends AbstractPropertyImpl<T> implements IProperty<T> {
|
||||
|
||||
private IReadOnlyProperty<T> readOnlyProperty;
|
||||
private IWriteOnlyProperty<T> writeOnlyProperty;
|
||||
|
||||
private final Validator<T> validator;
|
||||
|
||||
public PropertyImpl(IReadOnlyProperty<T> readOnlyPropertyIn, IWriteOnlyProperty<T> writeOnlyPropertyIn) {
|
||||
this(readOnlyPropertyIn, writeOnlyPropertyIn, null);
|
||||
}
|
||||
public PropertyImpl(IReadOnlyProperty<T> readOnlyPropertyIn, IWriteOnlyProperty<T> writeOnlyPropertyIn, Validator<T> validator) {
|
||||
this.readOnlyProperty = Objects.requireNonNull(readOnlyPropertyIn, "readOnlyPropertyIn cannot be null.");
|
||||
this.writeOnlyProperty = Objects.requireNonNull(writeOnlyPropertyIn, "writeOnlyPropertyIn cannot be null.");
|
||||
this.value = null;
|
||||
this.validator = validator;
|
||||
}
|
||||
|
||||
public PropertyImpl(T initialValue) {
|
||||
this(initialValue, null);
|
||||
}
|
||||
|
||||
public PropertyImpl(T initialValue, Validator<T> validator) {
|
||||
this.value = initialValue;
|
||||
this.readOnlyProperty = null;
|
||||
this.writeOnlyProperty = null;
|
||||
this.validator = validator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value for the property.
|
||||
*
|
||||
* @param valueIn the value to set for the property
|
||||
*/
|
||||
@Override
|
||||
public void set(T valueIn) {
|
||||
if (validator != null) {
|
||||
validator.validate(valueIn);
|
||||
}
|
||||
if (writeOnlyProperty != null) {
|
||||
writeOnlyProperty.set(valueIn);
|
||||
} else {
|
||||
this.value = valueIn;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the current value of the property.
|
||||
*
|
||||
* @return the current value of the property
|
||||
*/
|
||||
@Override
|
||||
public T get() {
|
||||
if (readOnlyProperty != null) {
|
||||
return readOnlyProperty.get();
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package com.openeggbert.jdotnet.JDotNet.Properties;
|
||||
|
||||
import com.openeggbert.jdotnet.JDotNet.JDotNetException;
|
||||
|
||||
public class PropertyVetoException extends JDotNetException {
|
||||
public PropertyVetoException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package com.openeggbert.jdotnet.JDotNet.Properties;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* A concrete implementation of a read-only property for a value of type T.
|
||||
*
|
||||
* This class extends AbstractPropertyImpl to inherit its protected "value" field
|
||||
* for storing the state of the property. As a read-only property, it implements
|
||||
* the IReadOnlyProperty interface, providing only a getter method to retrieve
|
||||
* the current value of the property while prohibiting any modifications.
|
||||
*
|
||||
* @param <T> the type of the property's value
|
||||
*/
|
||||
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ReadOnlyPropertyImpl<T> extends AbstractPropertyImpl<T> implements IReadOnlyProperty<T> {
|
||||
|
||||
/**
|
||||
* Retrieves the current value of the property.
|
||||
*
|
||||
* @return the current value of the property
|
||||
*/
|
||||
@Override
|
||||
public T get() {
|
||||
return value;
|
||||
}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
package com.openeggbert.jdotnet.JDotNet.Properties;
|
||||
@FunctionalInterface
|
||||
public interface Validator<T> {
|
||||
void validate(T value) throws IllegalArgumentException;
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package com.openeggbert.jdotnet.JDotNet.Properties;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* A concrete implementation of a write-only property for a value of type T.
|
||||
*
|
||||
* This class extends AbstractPropertyImpl, leveraging its protected "value" field
|
||||
* to store the property's data. It implements the IWriteOnlyProperty interface,
|
||||
* providing a setter method to modify the property's value while prohibiting
|
||||
* access to retrieve it.
|
||||
*
|
||||
* @param <T> the type of the property's value
|
||||
*/
|
||||
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class WriteOnlyPropertyImpl<T> extends AbstractPropertyImpl<T> implements IWriteOnlyProperty<T> {
|
||||
|
||||
/**
|
||||
* Sets the value for the property.
|
||||
*
|
||||
* @param valueIn the value to set for the property
|
||||
*/
|
||||
@Override
|
||||
public void set(T valueIn) {
|
||||
this.value = valueIn;
|
||||
}
|
||||
}
|
@ -16,7 +16,7 @@ import java.lang.annotation.Target;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE_USE)
|
||||
@AdditionalClassForDotNetSimulation
|
||||
@AdditionalClassForDotNetEmulation
|
||||
public @interface UnusedCode {
|
||||
String description() default "";
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
package com.openeggbert.jdotnet.JDotNet.Microsoft.Devices.Sensors;
|
||||
package com.openeggbert.jdotnet.Microsoft.Sensors;
|
||||
|
||||
/**
|
||||
*
|
@ -2,7 +2,7 @@
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
package com.openeggbert.jdotnet.JDotNet.Microsoft.Devices.Sensors;
|
||||
package com.openeggbert.jdotnet.Microsoft.Sensors;
|
||||
|
||||
import com.openeggbert.jdotnet.System.Exception_;
|
||||
|
@ -7,23 +7,22 @@ package com.openeggbert.jdotnet.System;
|
||||
import com.openeggbert.jdotnet.JDotNet.CSharpKeyWords.struct;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.NoArgsConstructor;
|
||||
import com.openeggbert.jdotnet.JDotNet.CSharpKeyWords.readonly;
|
||||
import com.openeggbert.jdotnet.JDotNet.CSharpKeyWords.const_;
|
||||
import com.openeggbert.jdotnet.JDotNet.CSharpKeyWords.readonly_;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author robertvokac
|
||||
*/
|
||||
@AllArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
@readonly
|
||||
@readonly_
|
||||
class Boolean extends struct<Boolean> {
|
||||
|
||||
protected Boolean() {
|
||||
this.m_value = false;
|
||||
//Not meant to be instantiated.
|
||||
}
|
||||
private @readonly final boolean m_value;
|
||||
private @readonly_
|
||||
final boolean m_value;
|
||||
public boolean get() {
|
||||
return m_value;
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
*/
|
||||
package com.openeggbert.jdotnet.System;
|
||||
|
||||
import com.openeggbert.jdotnet.JDotNet.AdditionalClassForDotNetSimulation;
|
||||
import com.openeggbert.jdotnet.JDotNet.AdditionalClassForDotNetEmulation;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
@ -18,7 +18,7 @@ import java.lang.annotation.Target;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.METHOD)
|
||||
@AdditionalClassForDotNetSimulation
|
||||
@AdditionalClassForDotNetEmulation
|
||||
public @interface Event {
|
||||
String description() default "Event handler";
|
||||
}
|
||||
|
@ -4,15 +4,21 @@
|
||||
*/
|
||||
package com.openeggbert.jdotnet.System;
|
||||
|
||||
import com.openeggbert.jdotnet.JDotNet.AdditionalClassForDotNetSimulation;
|
||||
import com.openeggbert.jdotnet.JDotNet.AdditionalClassForDotNetEmulation;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* An implementation of the EventHandler interface, responsible for managing
|
||||
* event listeners and invoking them when an event occurs.
|
||||
*
|
||||
* @author robertvokac
|
||||
* @param <T> The type of event arguments that will be passed to the listeners.
|
||||
*
|
||||
* This class simulates the behavior of C# event handling.
|
||||
* It allows adding and removing event listeners, as well as invoking them
|
||||
* with the provided event arguments.
|
||||
*/
|
||||
@AdditionalClassForDotNetSimulation
|
||||
@AdditionalClassForDotNetEmulation
|
||||
public class EventHandlerImpl<T> implements EventHandler<T> {
|
||||
|
||||
private final List<EventListener<T>> list = new ArrayList<>();
|
||||
|
@ -4,13 +4,13 @@
|
||||
*/
|
||||
package com.openeggbert.jdotnet.System;
|
||||
|
||||
import com.openeggbert.jdotnet.JDotNet.AdditionalClassForDotNetSimulation;
|
||||
import com.openeggbert.jdotnet.JDotNet.AdditionalClassForDotNetEmulation;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author robertvokac
|
||||
*/
|
||||
@AdditionalClassForDotNetSimulation
|
||||
@AdditionalClassForDotNetEmulation
|
||||
public interface EventListener<T>{
|
||||
|
||||
void onEventHappened(T eventArgs);
|
||||
|
@ -4,7 +4,7 @@
|
||||
*/
|
||||
package com.openeggbert.jdotnet.System.Resources;
|
||||
|
||||
import com.openeggbert.jdotnet.JDotNet.CSharpKeyWords.nullable;
|
||||
import com.openeggbert.jdotnet.JDotNet.CSharpKeyWords.nullable_;
|
||||
import com.openeggbert.jdotnet.System.Globalization.CultureInfo;
|
||||
import com.openeggbert.jdotnet.System.Reflection.Assembly;
|
||||
|
||||
@ -14,7 +14,7 @@ import com.openeggbert.jdotnet.System.Reflection.Assembly;
|
||||
*/
|
||||
public class ResourceManager {
|
||||
|
||||
public static String GetString(String name, @nullable CultureInfo culture) {
|
||||
public static String GetString(String name, @nullable_ CultureInfo culture) {
|
||||
return null;
|
||||
//todo
|
||||
}
|
||||
|
@ -10,8 +10,13 @@ import java.util.regex.Pattern;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* The String_ class provides a set of utility functions to work with strings,
|
||||
* including checks for null or empty strings, formatting operations with templates,
|
||||
* and character repetitions. Helper methods are included to support locale-based
|
||||
* string formatting and basic type-dependent formatting specifications.
|
||||
*
|
||||
* @author robertvokac
|
||||
* This class is not instantiable directly, and its utility methods are designed
|
||||
* to mirror .NET-style string handling while integrating Java principles.
|
||||
*/
|
||||
public class String_ {
|
||||
|
||||
@ -22,10 +27,28 @@ public class String_ {
|
||||
private String value;
|
||||
|
||||
|
||||
/**
|
||||
* Determines whether the specified string is either null or empty.
|
||||
*
|
||||
* @param string the string to check for null or emptiness.
|
||||
* @return true if the specified string is null or has a length of 0; false otherwise.
|
||||
*/
|
||||
public static boolean IsNullOrEmpty(String string) {
|
||||
return string == null || string.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats a template string by replacing placeholders in the form of `{index}` with corresponding
|
||||
* arguments from the provided list. The index must be a valid zero-based integer referencing
|
||||
* the `args` array.
|
||||
*
|
||||
* @param template the string template with placeholders in the format `{index}` to be replaced.
|
||||
* Must not be null.
|
||||
* @param args the array of objects to be used as replacements for the placeholders. Must not be null.
|
||||
* @return the formatted string with placeholders replaced by the corresponding arguments from `args`.
|
||||
* @throws IllegalArgumentException if `template` or `args` is null, if a placeholder is invalid,
|
||||
* or if the placeholder index is out of range.
|
||||
*/
|
||||
public static String Format(String template, Object... args) {
|
||||
if (template == null || args == null) {
|
||||
throw new IllegalArgumentException("Template and arguments must not be null.");
|
||||
@ -64,6 +87,14 @@ public class String_ {
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new instance of the String_ class, initializing its value with a repeated
|
||||
* sequence of the specified character.
|
||||
*
|
||||
* @param ch the character to be repeated to form the string value.
|
||||
* @param times the number of times to repeat the character. Must be non-negative.
|
||||
* @throws Exception_ if the value of the parameter `times` is less than 0.
|
||||
*/
|
||||
public String_(char ch, int times) {
|
||||
if(times < 0) {
|
||||
throw new Exception_("times cannot be less than 0");
|
||||
|
@ -9,8 +9,8 @@ import lombok.AllArgsConstructor;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author robertvokac
|
||||
* Represents a time interval and provides methods to manipulate and instantiate time intervals.
|
||||
* The time interval is internally stored in ticks.
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ -23,6 +23,11 @@ public class TimeSpan extends struct<TimeSpan> {
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* Creates a copy of the current TimeSpan instance.
|
||||
*
|
||||
* @return A new TimeSpan object with the same tick value as the current instance.
|
||||
*/
|
||||
public TimeSpan copy() {
|
||||
return new TimeSpan(_ticks);
|
||||
}
|
||||
|
@ -4,14 +4,14 @@
|
||||
*/
|
||||
package com.openeggbert.jdotnet.System;
|
||||
|
||||
import com.openeggbert.jdotnet.JDotNet.CSharpKeyWords.nullable;
|
||||
import com.openeggbert.jdotnet.JDotNet.CSharpKeyWords.nullable_;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author robertvokac
|
||||
*/
|
||||
public class object {
|
||||
public static boolean ReferenceEquals(@nullable Object objA, @nullable Object objB) {
|
||||
public static boolean ReferenceEquals(@nullable_ Object objA, @nullable_ Object objB) {
|
||||
if(objA == null && objB == null) {return true;}
|
||||
if(objA == null || objB == null) {return false;}
|
||||
return objA.equals(objB);
|
||||
|
Reference in New Issue
Block a user