-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
My current process is * Import checkstyle into project configuration. * Run Reformat Code on each module, with Optimize Imports and '*.java' file mask
- Loading branch information
Showing
35 changed files
with
355 additions
and
282 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
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
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
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
25 changes: 13 additions & 12 deletions
25
DashboardCore/src/main/java/com/acmerobotics/dashboard/config/reflection/ArrayProvider.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,55 @@ | ||
package com.acmerobotics.dashboard.config.reflection; | ||
|
||
import com.acmerobotics.dashboard.config.ValueProvider; | ||
|
||
import java.lang.reflect.Array; | ||
import java.lang.reflect.Field; | ||
|
||
public class ArrayProvider<T> implements ValueProvider<T> { | ||
private final Field field; | ||
private final Object parent; | ||
private final int[] indices; | ||
|
||
public ArrayProvider(Field field, Object parent, int... indices) { | ||
this.field = field; | ||
this.parent = parent; | ||
this.indices = indices; | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
@Override | ||
public T get() { | ||
try { | ||
return (T) getArrayRecursive(field.get(parent), indices); | ||
} catch (IllegalAccessException e) { | ||
throw new RuntimeException(e); | ||
} catch(ArrayIndexOutOfBoundsException e) | ||
{ | ||
} catch (ArrayIndexOutOfBoundsException e) { | ||
return null; | ||
} | ||
} | ||
|
||
@Override | ||
public void set(T value) { | ||
try { | ||
setArrayRecursive(field.get(parent), value, indices); | ||
} catch (IllegalAccessException e) { | ||
throw new RuntimeException(e); | ||
}catch(ArrayIndexOutOfBoundsException ignored) { } | ||
} catch (ArrayIndexOutOfBoundsException ignored) { | ||
} | ||
} | ||
|
||
|
||
public static Object getArrayRecursive(Object object, int[] indices) throws ArrayIndexOutOfBoundsException, IllegalAccessException | ||
{ | ||
public static Object getArrayRecursive(Object object, int[] indices) | ||
throws ArrayIndexOutOfBoundsException, IllegalAccessException { | ||
for (int index : indices) { | ||
object = Array.get(object, index); | ||
} | ||
return object; | ||
} | ||
public static void setArrayRecursive(Object object, Object value, int[] indices) | ||
{ | ||
for(int i=0;i< indices.length-1;i++) | ||
{ | ||
object=Array.get(object,indices[i]); | ||
|
||
public static void setArrayRecursive(Object object, Object value, int[] indices) { | ||
for (int i = 0; i < indices.length - 1; i++) { | ||
object = Array.get(object, indices[i]); | ||
} | ||
Array.set(object,indices[indices.length-1], value); | ||
Array.set(object, indices[indices.length - 1], value); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
DashboardCore/src/main/java/com/acmerobotics/dashboard/config/reflection/FieldProvider.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
Oops, something went wrong.