fixing typos in readme file, introducing var local type inference where possible

This commit is contained in:
Michal Krzywanski
2020-08-23 11:00:15 +02:00
parent 3d9afbaeec
commit e65b65257e
8 changed files with 26 additions and 29 deletions

View File

@ -23,7 +23,6 @@
package com.iluwatar.filterer;
import com.iluwatar.filterer.threat.ProbabilisticThreatAwareSystem;
import com.iluwatar.filterer.threat.ProbableThreat;
import com.iluwatar.filterer.threat.SimpleProbabilisticThreatAwareSystem;
import com.iluwatar.filterer.threat.SimpleProbableThreat;
@ -65,24 +64,22 @@ public class App {
private static void filteringSimpleProbableThreats() {
LOGGER.info(" ### Filtering ProbabilisticThreatAwareSystem by probability ###");
ProbableThreat trojanArcBomb =
new SimpleProbableThreat("Trojan-ArcBomb", 1, ThreatType.TROJAN, 0.99);
ProbableThreat rootkit =
new SimpleProbableThreat("Rootkit-Kernel", 2, ThreatType.ROOTKIT, 0.8);
var trojanArcBomb = new SimpleProbableThreat("Trojan-ArcBomb", 1, ThreatType.TROJAN, 0.99);
var rootkit = new SimpleProbableThreat("Rootkit-Kernel", 2, ThreatType.ROOTKIT, 0.8);
List<ProbableThreat> probableThreats = List.of(trojanArcBomb, rootkit);
ProbabilisticThreatAwareSystem probabilisticThreatAwareSystem =
new SimpleProbabilisticThreatAwareSystem("System-1", probableThreats);
var probabilisticThreatAwareSystem =
new SimpleProbabilisticThreatAwareSystem("Sys-1", probableThreats);
LOGGER.info("Filtering ProbabilisticThreatAwareSystem. Initial : "
+ probabilisticThreatAwareSystem);
//Filtering using filterer
ProbabilisticThreatAwareSystem filtered = probabilisticThreatAwareSystem.filtered()
var filteredThreatAwareSystem = probabilisticThreatAwareSystem.filtered()
.by(probableThreat -> Double.compare(probableThreat.probability(), 0.99) == 0);
LOGGER.info("Filtered by probability = 0.99 : " + filtered);
LOGGER.info("Filtered by probability = 0.99 : " + filteredThreatAwareSystem);
}
/**
@ -93,16 +90,16 @@ public class App {
private static void filteringSimpleThreats() {
LOGGER.info("### Filtering ThreatAwareSystem by ThreatType ###");
Threat rootkit = new SimpleThreat(ThreatType.ROOTKIT, 1, "Simple-Rootkit");
Threat trojan = new SimpleThreat(ThreatType.TROJAN, 2, "Simple-Trojan");
var rootkit = new SimpleThreat(ThreatType.ROOTKIT, 1, "Simple-Rootkit");
var trojan = new SimpleThreat(ThreatType.TROJAN, 2, "Simple-Trojan");
List<Threat> threats = List.of(rootkit, trojan);
ThreatAwareSystem threatAwareSystem = new SimpleThreatAwareSystem("System-1", threats);
var threatAwareSystem = new SimpleThreatAwareSystem("Sys-1", threats);
LOGGER.info("Filtering ThreatAwareSystem. Initial : " + threatAwareSystem);
//Filtering using Filterer
ThreatAwareSystem rootkitThreatAwareSystem = threatAwareSystem.filtered()
var rootkitThreatAwareSystem = threatAwareSystem.filtered()
.by(threat -> threat.type() == ThreatType.ROOTKIT);
LOGGER.info("Filtered by threatType = ROOTKIT : " + rootkitThreatAwareSystem);

View File

@ -93,7 +93,7 @@ public class SimpleProbabilisticThreatAwareSystem implements ProbabilisticThreat
if (o == null || getClass() != o.getClass()) {
return false;
}
SimpleProbabilisticThreatAwareSystem that = (SimpleProbabilisticThreatAwareSystem) o;
var that = (SimpleProbabilisticThreatAwareSystem) o;
return systemId.equals(that.systemId)
&& threats.equals(that.threats);
}

View File

@ -60,7 +60,7 @@ public class SimpleProbableThreat extends SimpleThreat implements ProbableThreat
if (!super.equals(o)) {
return false;
}
SimpleProbableThreat that = (SimpleProbableThreat) o;
var that = (SimpleProbableThreat) o;
return Double.compare(that.probability, probability) == 0;
}

View File

@ -79,7 +79,7 @@ public class SimpleThreat implements Threat {
if (o == null || getClass() != o.getClass()) {
return false;
}
SimpleThreat that = (SimpleThreat) o;
var that = (SimpleThreat) o;
return id == that.id
&& threatType == that.threatType
&& Objects.equals(name, that.name);

View File

@ -87,7 +87,7 @@ public class SimpleThreatAwareSystem implements ThreatAwareSystem {
if (o == null || getClass() != o.getClass()) {
return false;
}
SimpleThreatAwareSystem that = (SimpleThreatAwareSystem) o;
var that = (SimpleThreatAwareSystem) o;
return systemId.equals(that.systemId)
&& issues.equals(that.issues);
}

View File

@ -33,15 +33,15 @@ class SimpleProbabilisticThreatAwareSystemTest {
@Test
void shouldFilterByProbability() {
//given
ProbableThreat trojan = new SimpleProbableThreat("Troyan-ArcBomb", 1, ThreatType.TROJAN, 0.99);
ProbableThreat rootkit = new SimpleProbableThreat("Rootkit-System", 2, ThreatType.ROOTKIT, 0.8);
var trojan = new SimpleProbableThreat("Troyan-ArcBomb", 1, ThreatType.TROJAN, 0.99);
var rootkit = new SimpleProbableThreat("Rootkit-System", 2, ThreatType.ROOTKIT, 0.8);
List<ProbableThreat> probableThreats = List.of(trojan, rootkit);
ProbabilisticThreatAwareSystem simpleProbabilisticThreatAwareSystem =
var simpleProbabilisticThreatAwareSystem =
new SimpleProbabilisticThreatAwareSystem("System-1", probableThreats);
//when
ProbabilisticThreatAwareSystem filtered = simpleProbabilisticThreatAwareSystem.filtered()
var filtered = simpleProbabilisticThreatAwareSystem.filtered()
.by(probableThreat -> Double.compare(probableThreat.probability(), 0.99) == 0);
//then

View File

@ -33,14 +33,14 @@ class SimpleThreatAwareSystemTest {
@Test
void shouldFilterByThreatType() {
//given
Threat rootkit = new SimpleThreat(ThreatType.ROOTKIT, 1, "Simple-Rootkit");
Threat trojan = new SimpleThreat(ThreatType.TROJAN, 2, "Simple-Trojan");
var rootkit = new SimpleThreat(ThreatType.ROOTKIT, 1, "Simple-Rootkit");
var trojan = new SimpleThreat(ThreatType.TROJAN, 2, "Simple-Trojan");
List<Threat> threats = List.of(rootkit, trojan);
ThreatAwareSystem threatAwareSystem = new SimpleThreatAwareSystem("System-1", threats);
var threatAwareSystem = new SimpleThreatAwareSystem("System-1", threats);
//when
ThreatAwareSystem rootkitThreatAwareSystem = threatAwareSystem.filtered()
var rootkitThreatAwareSystem = threatAwareSystem.filtered()
.by(threat -> threat.type() == ThreatType.ROOTKIT);
//then