-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from FIRSTTeam6423/monologue-rewrite
Merge monologue rewrite into main
- Loading branch information
Showing
50 changed files
with
5,768 additions
and
1,193 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
// Copyright (c) 2025 FRC 6423 - Ward Melville Iron Patriots | ||
// https://github.com/FIRSTTeam6423 | ||
// | ||
// Open Source Software; you can modify and/or share it under the terms of | ||
// MIT license file in the root directory of this project | ||
|
||
package monologue; | ||
|
||
import java.lang.annotation.Annotation; | ||
import java.lang.annotation.Documented; | ||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
@SuppressWarnings("unchecked") | ||
public class Annotations { | ||
static final Class<? extends Annotation>[] ALL_ANNOTATIONS = | ||
new Class[] {Log.class, Log.Once.class}; | ||
|
||
/** | ||
* Logs the annotated field/method to NetworkTables if inside a {@link Logged} class. | ||
* | ||
* <p>Static fields and methods will emit a warning and not be logged. | ||
* | ||
* @param key [optional] the key to log the variable as. If empty, the key will be the name of the | ||
* field/method | ||
* @param sink [optional] the log sink to use | ||
*/ | ||
@Documented | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target({ElementType.FIELD, ElementType.METHOD}) | ||
public @interface Log { | ||
|
||
/** The relative path to log to. If empty, the path will be the name of the field/method. */ | ||
public String key() default ""; | ||
|
||
/** The {@link LogSink} to use. */ | ||
public LogSink sink() default LogSink.NT; | ||
|
||
/** | ||
* Logs the annotated field/method to NetworkTables if inside a {@link Logged} class. | ||
* | ||
* @param key [optional] the key to log the variable as. If empty, the key will be the name of | ||
* the field/method | ||
*/ | ||
@Documented | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target({ElementType.FIELD, ElementType.METHOD}) | ||
public @interface Once { | ||
/** The relative path to log to. If empty, the path will be the name of the field/method. */ | ||
public String key() default ""; | ||
|
||
/** The {@link LogSink} to use. */ | ||
public LogSink sink() default LogSink.NT; | ||
} | ||
} | ||
|
||
/** | ||
* Makes the annotated field containing a {@link Logged} class not be recursed into. | ||
* | ||
* @apiNote this will also make fields inside the object in the field not be logged | ||
*/ | ||
@Documented | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target({ElementType.FIELD}) | ||
public @interface IgnoreLogged {} | ||
|
||
/** | ||
* Allows singletons to be logged only once with a predefined key. | ||
* | ||
* <p>This also allows static variables to be logged under the singleton's key. | ||
* | ||
* @param key the key to log at, still appends the class name | ||
*/ | ||
@Documented | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target({ElementType.TYPE}) | ||
public @interface SingletonLogged { | ||
public String key(); | ||
} | ||
|
||
/** | ||
* Will cause the internal fields of the annotated field to be logged as if they were fields of | ||
* the object this field is in. This is useful for flattening complex objects into a single path. | ||
*/ | ||
@Documented | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target({ElementType.FIELD}) | ||
public @interface FlattenedLogged {} | ||
|
||
/** | ||
* Will make Monologue aware that this field could contain an object that implements {@link | ||
* Logged} but the type of the field itself does not implement {@link Logged}. | ||
*/ | ||
@Documented | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target({ElementType.FIELD}) | ||
public @interface MaybeLoggedType {} | ||
|
||
@Documented | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target({ElementType.FIELD}) | ||
public @interface OptionalLogged { | ||
public Class<? extends Logged> type(); | ||
} | ||
} |
Oops, something went wrong.