Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove explicit types and replace with '<>' #582

Merged
merged 1 commit into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/main/java/emissary/command/WhatCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public String getCommandName() {
private boolean recursive = false;

protected List<IServiceProviderPlace> places;
protected List<String> placeLabels = new ArrayList<String>();
protected List<String> placeLabels = new ArrayList<>();
protected Set<String> textPlaces;
// protected DropOffUtil dropOffUtil;
private ParserFactory parserFactory;
Expand Down Expand Up @@ -97,7 +97,7 @@ public void setupWhat() {
parserFactory = new ParserFactory();
final Configurator configG = ConfigUtil.getConfigInfo(this.getClass());
final List<String> placeNames = configG.findEntries("PLACE");
this.places = new ArrayList<IServiceProviderPlace>();
this.places = new ArrayList<>();
for (final String entry : placeNames) {
final String[] parts = entry.split("/");
final String instanceName = parts[0];
Expand Down Expand Up @@ -217,7 +217,7 @@ protected Identification identify(@Nullable final IBaseDataObject b, final boole
private Identification runEngines(@Nullable final IBaseDataObject b) {

final Identification ident = new Identification();
final List<String> typesFound = new ArrayList<String>();
final List<String> typesFound = new ArrayList<>();

if (b != null && b.dataLength() == 0) {
ident.addType(Form.EMPTY);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/emissary/core/HDMobileAgent.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class HDMobileAgent extends MobileAgent {
static final long serialVersionUID = 786319119844306571L;

// What we carry around with us
protected List<IBaseDataObject> payloadList = Collections.synchronizedList(new ArrayList<IBaseDataObject>());
protected List<IBaseDataObject> payloadList = Collections.synchronizedList(new ArrayList<>());

/**
* Still have the uncaught exception handler but not really in a true ThreadGroup
Expand Down Expand Up @@ -218,7 +218,7 @@ protected void agentControl(final IServiceProviderPlace currentPlaceArg) {
atPlaceHD(currentPlace, this.payloadList);
} else {
// Add the primary payload object to a list
final List<IBaseDataObject> toBeProcessed = new ArrayList<IBaseDataObject>();
final List<IBaseDataObject> toBeProcessed = new ArrayList<>();
toBeProcessed.add(mypayload);

// Add any other payload that has the same current form
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/emissary/core/MetricsManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ public class MetricsManager {
public static final String DEFAULT_NAMESPACE_NAME = "MetricsManager";

@SuppressWarnings("rawtypes")
public static final SortedMap<String, Gauge> EMPTY_GUAGES = new TreeMap<String, Gauge>();
public static final SortedMap<String, Counter> EMPTY_COUNTERS = new TreeMap<String, Counter>();
public static final SortedMap<String, Histogram> EMPTY_HISTOGRAMS = new TreeMap<String, Histogram>();
public static final SortedMap<String, Meter> EMPTY_METERS = new TreeMap<String, Meter>();
public static final SortedMap<String, Gauge> EMPTY_GUAGES = new TreeMap<>();
public static final SortedMap<String, Counter> EMPTY_COUNTERS = new TreeMap<>();
public static final SortedMap<String, Histogram> EMPTY_HISTOGRAMS = new TreeMap<>();
public static final SortedMap<String, Meter> EMPTY_METERS = new TreeMap<>();

protected static final Logger logger = LoggerFactory.getLogger(MetricsManager.class);

Expand Down Expand Up @@ -76,7 +76,7 @@ public MetricsManager(final Configurator conf) {
}

public void logMetrics(final Map<String, Timer> stats) {
final SortedMap<String, Timer> m = new TreeMap<String, Timer>();
final SortedMap<String, Timer> m = new TreeMap<>();
m.putAll(stats);
this.reporter.report(EMPTY_GUAGES, EMPTY_COUNTERS, EMPTY_HISTOGRAMS, EMPTY_METERS, m);
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/emissary/kff/KffChain.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
public class KffChain {
private static final Logger logger = LoggerFactory.getLogger(KffChain.class);

protected List<KffFilter> list = new ArrayList<KffFilter>();
protected List<KffFilter> list = new ArrayList<>();

// Smaller than this and we don't report a hit
protected int KFF_MIN_DATA_SIZE = 0;

// The algorithms to compute
protected List<String> algorithms = new ArrayList<String>();
protected List<String> algorithms = new ArrayList<>();

/**
* Construct an empty KFF Chain
Expand Down Expand Up @@ -109,7 +109,7 @@ public boolean removeAlgorithm(String alg) {
* @see java.security.MessageDigest#getInstance(String)
*/
public List<String> getAlgorithms() {
List<String> list = new ArrayList<String>(algorithms);
List<String> list = new ArrayList<>(algorithms);
return list;
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/emissary/kff/KffDataObjectHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public Map<String, String> hashData(byte[] data, String name) {
* @return parameter entries suitable for a BaseDataObject
*/
public Map<String, String> hashData(@Nullable byte[] data, String name, @Nullable String prefix) {
Map<String, String> results = new HashMap<String, String>();
Map<String, String> results = new HashMap<>();

if (prefix == null) {
prefix = "";
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/emissary/kff/KffMemcached.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public KffMemcached(String testIdWithSpaces, String filterName, FilterType dupli

// Load up the list of servers
Set<String> serversFromConfig = configG.findEntriesAsSet("MEMCACHED_SERVER");
List<InetSocketAddress> servers = new LinkedList<InetSocketAddress>();
List<InetSocketAddress> servers = new LinkedList<>();
for (String serverFromConfig : serversFromConfig) {
// Transform to an InetSocketAddress
if (serverFromConfig.contains(":")) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/emissary/kff/KffResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class KffResult implements Serializable {
long crc32 = -1L;
String ssdeep = null;

Map<String, byte[]> hashComp = new TreeMap<String, byte[]>();
Map<String, byte[]> hashComp = new TreeMap<>();

/**
* Create an empty result object
Expand Down Expand Up @@ -233,7 +233,7 @@ public String getResultString(String alg) {
* Get names of all algorithm results present
*/
public Set<String> getResultNames() {
return new TreeSet<String>(hashComp.keySet());
return new TreeSet<>(hashComp.keySet());
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/emissary/output/DropOffUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ public String getBestIdFrom(final IBaseDataObject d) {
* @return id
*/
public String[] getExistingIds(final IBaseDataObject d) {
final List<String> values = new ArrayList<String>();
final List<String> values = new ArrayList<>();
for (final String s : this.idTokens) {
if (!StringUtils.isBlank(d.getStringParameter(s))) {
values.add(d.getStringParameter(s));
Expand Down Expand Up @@ -1006,7 +1006,7 @@ public void processMetadata(final List<IBaseDataObject> payloadList) {

// Keep track of parent's filetype to output
// relies on the attachments being sorted
final Map<String, String> parentTypes = new HashMap<String, String>();
final Map<String, String> parentTypes = new HashMap<>();
final IBaseDataObject tld = payloadList.get(0);
final List<String> extended_filetypes = new ArrayList<>();
parentTypes.put("1", tld.getFileType());
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/emissary/output/filter/AbstractFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ protected void loadFilterConfiguration(@Nullable final Configurator suppliedFilt
return;
}

final List<String> configPreferences = new ArrayList<String>();
final List<String> configPreferences = new ArrayList<>();

if (getFilterName() != null) {
configPreferences.add(this.getClass().getPackage().getName() + "." + getFilterName() + ConfigUtil.CONFIG_FILE_ENDING);
Expand Down Expand Up @@ -412,7 +412,7 @@ protected boolean isOutputtable(final Collection<String> types) {

final boolean canOutput = !Collections.disjoint(this.outputTypes, types);
if (canOutput && this.logger.isDebugEnabled()) {
final Set<String> outputFor = new HashSet<String>();
final Set<String> outputFor = new HashSet<>();
for (final String s : this.outputTypes) {
if (types.contains(s)) {
outputFor.add(s);
Expand Down Expand Up @@ -440,7 +440,7 @@ protected Set<String> getTypesToCheck(final IBaseDataObject d) {
}

protected Set<String> getTypesToCheckForNamedView(final IBaseDataObject d, final String viewName) {
final Set<String> checkTypes = new HashSet<String>();
final Set<String> checkTypes = new HashSet<>();
final String lang = this.dropOffUtil.getLanguage(d);
final String fileType = DropOffUtil.getFileType(d);
final String currentForm = d.currentForm();
Expand Down Expand Up @@ -500,6 +500,6 @@ public String getErrorSpec() {

@Override
public Collection<String> getOutputTypes() {
return new HashSet<String>(this.outputTypes);
return new HashSet<>(this.outputTypes);
}
}
2 changes: 1 addition & 1 deletion src/main/java/emissary/parser/DataIdentifier.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class DataIdentifier {
protected int DATA_ID_STR_SZ = 100;

// Things we know how to identify
protected Map<String, String> TYPES = new HashMap<String, String>();
protected Map<String, String> TYPES = new HashMap<>();

/**
* Create the id engine
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/emissary/parser/SessionProducer.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public SessionProducer(SessionParser sp, String myKey, List<String> initialForms
*/
public SessionProducer(SessionParser sp, String initialForm) {
this.sp = sp;
this.initialForms = new ArrayList<String>();
this.initialForms = new ArrayList<>();
this.initialForms.add(initialForm);
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/emissary/parser/SimpleNioParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ protected DecomposedSession decomposeSession(@Nullable InputSession session) thr
Map<String, Object> md = session.getMetaData();
if (md != null) {
Map<String, String> cooked = cookMetaRecords(md);
d.setMetaData(new HashMap<String, Object>()); // clear
d.setMetaData(new HashMap<>()); // clear
for (Map.Entry<String, String> entry : cooked.entrySet()) {
d.addMetaData(entry.getKey(), entry.getValue());
}
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/emissary/pickup/PickUpSpace.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@
*/
public abstract class PickUpSpace extends emissary.pickup.PickUpPlace implements IPickUpSpace {
// List of workspace instances to interact with
protected List<String> openSpaceNames = new ArrayList<String>();
protected List<String> openSpaceNames = new ArrayList<>();

// Map of how many consecutive take errors by workspace name
protected Map<String, Integer> numConsecutiveTakeErrors = new HashMap<String, Integer>();
protected Map<String, Integer> numConsecutiveTakeErrors = new HashMap<>();

// Comms adapter
protected WorkSpaceAdapter tpa = new WorkSpaceAdapter();

// Map of last bundle size by workspace name
protected Map<String, Integer> lastBundleSize = new HashMap<String, Integer>();
protected Map<String, Integer> lastBundleSize = new HashMap<>();

// Map of pending bundles to workspace name to facilitate replying
protected Map<String, String> pendingBundles = new HashMap<String, String>();
protected Map<String, String> pendingBundles = new HashMap<>();

// Number of consecutive take errors that cause space to close
protected int TAKE_ERROR_MAX = 10;
Expand Down Expand Up @@ -119,7 +119,7 @@ public String getSpaceName() {
*/
@Override
public List<String> getSpaceNames() {
return new ArrayList<String>(openSpaceNames);
return new ArrayList<>(openSpaceNames);
}

/**
Expand All @@ -144,7 +144,7 @@ public boolean take() {
}

// Keep track of space we may have to close
List<String> closers = new ArrayList<String>();
List<String> closers = new ArrayList<>();

// We will take up to one bundle per workspace
int countTaken = 0;
Expand Down Expand Up @@ -185,7 +185,7 @@ public boolean take() {
* @param forceClosers additional spaces to close
*/
protected void cleanupFailedSpaces(List<String> forceClosers) {
List<String> closers = new ArrayList<String>(forceClosers);
List<String> closers = new ArrayList<>(forceClosers);
for (String s : openSpaceNames) {
if (getNumConsecutiveTakeErrors(s) > TAKE_ERROR_MAX) {
logger.error("Closing down space " + s + " due to repeated errors");
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/emissary/pickup/PickupQueue.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/
public class PickupQueue {
// Data structure for the bundles
protected final LinkedList<WorkBundle> queue = new LinkedList<WorkBundle>();
protected final LinkedList<WorkBundle> queue = new LinkedList<>();

// Our logger
private static final Logger logger = LoggerFactory.getLogger(PickupQueue.class);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/emissary/pickup/file/FilePickUpPlace.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class FilePickUpPlace extends PickUpPlace implements IPickUp {
protected int pollingInterval = 30000;

// List of FileDataServer objects
protected List<FileDataServer> theDataServer = new ArrayList<FileDataServer>();
protected List<FileDataServer> theDataServer = new ArrayList<>();

// How many files the FileDataServer should group
protected int BUNDLE_SIZE = 20;
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/emissary/place/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,21 +85,21 @@ public class Main {
/** Regex for which metadata to print out */
protected String[] metaPatterns;
/** hash of parameters/values to set before process */
protected HashMap<String, String> params = new HashMap<String, String>();
protected HashMap<String, String> params = new HashMap<>();
/** Set to turn off Emissary node context and directory setup */
protected boolean runWithoutContext = false;
/** The command line options */
protected Options options = getStandardOptions();
/** set of alt views to print after processing */
protected Set<String> viewsToPrint = new HashSet<String>();
protected Set<String> viewsToPrint = new HashSet<>();
/** Class name of parser to run on input data */
protected String parserName = SimpleParser.class.getName();
/** Number of threads to use to process input files */
protected int numThreads = 1;
/** The workers that call the place */
List<Worker> workers = new ArrayList<Worker>();
List<Worker> workers = new ArrayList<>();
/** Queue of payload object for workers to pull from */
protected final LinkedList<IBaseDataObject> workQueue = new LinkedList<IBaseDataObject>();
protected final LinkedList<IBaseDataObject> workQueue = new LinkedList<>();
/** hashing support */
protected KffDataObjectHandler kff = null;
/** loop on input */
Expand Down Expand Up @@ -348,7 +348,7 @@ public void setRunWithoutContext(boolean val) {
* @return the list of file arguments or an empty list
*/
public List<String> getFileArgs() {
List<String> l = new ArrayList<String>();
List<String> l = new ArrayList<>();
for (int i = 0; fileArgs != null && i < fileArgs.length; i++) {
l.add(fileArgs[i]);
}
Expand Down Expand Up @@ -914,7 +914,7 @@ public void queuePayload(IBaseDataObject payload) {
* Called by the Worker consumer to process the given payload
*/
public void processPayload(IBaseDataObject payload) {
List<IBaseDataObject> attachments = new ArrayList<IBaseDataObject>();
List<IBaseDataObject> attachments = new ArrayList<>();
MDC.put(MDCConstants.SHORT_NAME, payload.shortName());
try {
boolean shouldContinue = preProcessHook(payload, attachments);
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/emissary/pool/MoveSpool.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class MoveSpool implements Runnable {
private static final Logger logger = LoggerFactory.getLogger(MoveSpool.class);

// The payload FIFO
protected final LinkedList<SpoolItem> spool = new LinkedList<SpoolItem>();
protected final LinkedList<SpoolItem> spool = new LinkedList<>();

// Reference to the agent pool
protected AgentPool pool;
Expand All @@ -45,7 +45,7 @@ public class MoveSpool implements Runnable {
public static final String NAMESPACE_NAME = "ArrivalSpool";

// Stats on how many moves and for what types arrived here
public final Map<String, Integer> moveCountMap = new HashMap<String, Integer>();
public final Map<String, Integer> moveCountMap = new HashMap<>();

// Stats collection
private int highWaterMark = 0;
Expand Down Expand Up @@ -345,7 +345,7 @@ public static MoveSpool lookup() throws NamespaceException {
*/
public Map<String, Integer> getMoveCountMap() {
synchronized (moveCountMap) {
return new HashMap<String, Integer>(moveCountMap);
return new HashMap<>(moveCountMap);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/emissary/util/FileComparator.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public static void main(String[] args) {

File dir = new File(args[0]);
File[] fileList = dir.listFiles();
List<File> fileVector = new ArrayList<File>();
List<File> fileVector = new ArrayList<>();
for (int i = 0; i < fileList.length; i++) {
// System.out.println(fileList[i].getName() + " " + fileList[i].length());
fileVector.add(fileList[i]);
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/emissary/util/MagicNumberUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public final class MagicNumberUtil {
private static final Logger log = LoggerFactory.getLogger(MagicNumberUtil.class);

/** The magic number instances */
private final List<MagicNumber> magicNumbers = new ArrayList<MagicNumber>();
private final List<MagicNumber> magicNumbers = new ArrayList<>();

/**
* Log flag for storing parse errors - they will just be discarded. Switching this on will allow erroneous entries to be
Expand All @@ -96,13 +96,13 @@ public final class MagicNumberUtil {
* Log data structure for continuations. Maps entries with depth 0 with a List of continuation entries containing the
* errors
*/
private final Map<String, List<String>> extErrorMap = new TreeMap<String, List<String>>();
private final Map<String, List<String>> extErrorMap = new TreeMap<>();

/**
* Log data structure for entries with a depth of '0' - these are the important entries. Just maintains a simple list of
* these entries
*/
private final List<String> errorList = new ArrayList<String>();
private final List<String> errorList = new ArrayList<>();

/**
* Private Constructor
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/emissary/util/ThreadDump.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public ThreadInfo[] getThreadInfo() {

public ThreadInfo[] getThreadInfo(final boolean excludeSystem) {
final ThreadInfo[] t = getThreadInfo();
final List<ThreadInfo> l = new ArrayList<ThreadInfo>();
final List<ThreadInfo> l = new ArrayList<>();
if (excludeSystem) {
for (final ThreadInfo ti : t) {
if (ti == null) {
Expand Down
Loading