MCPcopy Create free account
hub / github.com/Berkeley-CS61B/skeleton-sp23 / getFields

Method getFields

proj1a/tests/NodeChecker.java:145–155  ·  view source on GitHub ↗

This method gets fields of specified type from a given class. @param clazz the class you want to check @param type the type of field you want @return a list of fields matching the given type

(Class<?> clazz, Class<?> type)

Source from the content-addressed store, hash-verified

143 * @return a list of fields matching the given type
144 */
145 private static List<Field> getFields(Class<?> clazz, Class<?> type) {
146 Field[] fields = clazz.getDeclaredFields();
147 List<Field> namedFields = new ArrayList<>();
148 for (Field f : fields) {
149 f.setAccessible(true);
150 if (f.getType().equals(type)) {
151 namedFields.add(f);
152 }
153 }
154 return namedFields;
155 }
156
157 /**
158 * This method checks whether iterating through a list forwards and backwards

Callers 4

testNoFieldsMethod · 0.80

Calls 1

equalsMethod · 0.45

Tested by

no test coverage detected