@@ -28,8 +28,6 @@ import cz.vutbr.fit.interlockSim.sim.InOutWorker
2828import cz.vutbr.fit.interlockSim.sim.LoopProcess
2929import cz.vutbr.fit.interlockSim.sim.ShuntingLoop
3030import cz.vutbr.fit.interlockSim.exceptions.SimulationException
31- import cz.vutbr.fit.interlockSim.exceptions.requireEditor
32- import cz.vutbr.fit.interlockSim.exceptions.requireEditorNotNull
3331import cz.vutbr.fit.interlockSim.exceptions.requireSimulation
3432import cz.vutbr.fit.interlockSim.exceptions.requireSimulationNotNull
3533import cz.vutbr.fit.interlockSim.exceptions.requireValidArgument
@@ -245,11 +243,9 @@ abstract class DefaultContext :
245243 val nodecell2: NodeCell = Util .assertNodeCell(getGrid().get(key2)!! )
246244
247245 for (s1: Segment in nodecell1.joins()) {
248- requireEditorNotNull(s1) { " Segment s1 cannot be null for nodecell $nodecell1 " }
249246 val p1 = s1.transform(key1)
250247 if (used(p1)) continue
251248 for (s2: Segment in nodecell2.joins()) {
252- requireEditorNotNull(s2) { " Segment s2 cannot be null for nodecell $nodecell2 " }
253249 if (s1 == s2) continue // stejne segmenty se nepropoji
254250 val p2 = s2.transform(key2)
255251 if (used(p2)) continue
@@ -284,7 +280,6 @@ abstract class DefaultContext :
284280 key2 : Point ,
285281 trackBlock : TrackBlock
286282 ): Boolean {
287- requireEditor(key1 != null && key2 != null ) { " Keys cannot be null in hardJoin" }
288283 if (key1.distance(key2) > SQRT2 ) {
289284 val blockEndFrom = s1.transform(key1)
290285 val blockEndTo = s2.transform(key2)
@@ -321,7 +316,6 @@ abstract class DefaultContext :
321316 key2 : Point ,
322317 trackBlock : TrackBlock
323318 ): Map <Point , TrackBlockPart >? {
324- if (pi1 == null || pi2 == null ) throw IllegalArgumentException ()
325319 val p1 = pi1
326320 val p2 = pi2
327321
@@ -359,8 +353,8 @@ abstract class DefaultContext :
359353 key2 : Point ,
360354 trackBlock : TrackBlock
361355 ): MutableMap <Point , TrackBlockPart >? {
362- requireValidArgument(bresenham != null && bresenham .isNotEmpty()) {
363- " Bresenham path list cannot be null or empty"
356+ requireValidArgument(bresenham.isNotEmpty()) {
357+ " Bresenham path list cannot be empty"
364358 }
365359 val map: MutableMap <Point , TrackBlockPart > = linkedMapOf()
366360 var from = key1
@@ -394,7 +388,6 @@ abstract class DefaultContext :
394388 to : Point ,
395389 block : TrackBlock
396390 ): TrackBlockPart ? {
397- requireEditorNotNull(block) { " TrackBlock cannot be null in createPart" }
398391 if (used(middle)) return null
399392 if (from == to || from == middle || middle == to) return null
400393
@@ -426,9 +419,6 @@ abstract class DefaultContext :
426419 p2 : Point ,
427420 points : MutableList <Point >
428421 ): Boolean {
429- requireValidArgument(key1 != null && key2 != null && p1 != null && p2 != null ) {
430- " All points must be non-null in bresenham algorithm"
431- }
432422 requireValidArgument(key1 != p1 && key2 != p2 && key1 != p2 && key2 != p1) {
433423 " Keys and intermediate points must be distinct in bresenham algorithm"
434424 }
@@ -548,7 +538,6 @@ abstract class DefaultContext :
548538 key : Point ,
549539 nodeCell : NodeCell
550540 ) {
551- requireEditorNotNull(key) { " Cell key cannot be null in putCell" }
552541 // Validate coordinates are within grid bounds
553542 if (key.x < 0 || key.y < 0 || key.x >= railwayNetGrid.getCols() || key.y >= railwayNetGrid.getRows()) {
554543 throw ContextCreationException (
@@ -560,7 +549,6 @@ abstract class DefaultContext :
560549
561550 // vedlejsi Nody (sousedni bunky)
562551 for (s1: Segment in nodeCell.joins()) {
563- requireEditorNotNull(s1) { " Segment s1 cannot be null for nodeCell $nodeCell " }
564552 val p = s1.transform(key)
565553 // Skip neighbor if it's outside grid bounds (boundary cells)
566554 if (p.x < 0 || p.y < 0 || p.x >= railwayNetGrid.getCols() || p.y >= railwayNetGrid.getRows()) {
@@ -619,7 +607,6 @@ abstract class DefaultContext :
619607 * Remove a track line from the railway network
620608 */
621609 override fun removeLine (line : TrackBlock ) {
622- requireEditorNotNull(line) { " TrackBlock line cannot be null in removeLine" }
623610 extendedUnorientedGraph.remove(line)
624611 getGrid().keySet().removeAll(linesKeys.remove(line) ? : emptySet())
625612 changeSupport.firePropertyChange(
@@ -656,7 +643,6 @@ abstract class DefaultContext :
656643 ): Segment ? {
657644 // If track is not null, use it; otherwise use secondEndTrack
658645 if (track != null ) return getSegment(separator, track)
659- requireValidArgument(separator != null ) { " PathSeparator cannot be null" }
660646 requireValidArgument(secondEndTrack != null ) { " secondEndTrack cannot be null for separator $separator " }
661647 requireValidArgument(separator is OrientedPathSeparator ) {
662648 " PathSeparator must be OrientedPathSeparator, got ${separator.javaClass.simpleName} "
@@ -673,9 +659,6 @@ abstract class DefaultContext :
673659 separator : PathSeparator ,
674660 track : Track
675661 ): Segment ? {
676- if (separator == null || track == null ) {
677- throw IllegalArgumentException (" separator or track is null" )
678- }
679662 return if (track is TrackSection ) {
680663 @Suppress(" UNCHECKED_CAST" )
681664 val section = track as TrackSection
@@ -696,9 +679,6 @@ abstract class DefaultContext :
696679 separator : PathSeparator ,
697680 section : TrackSection
698681 ): Segment ? {
699- if (section == null ) {
700- throw IllegalArgumentException (" section is null" )
701- }
702682 val trackBlock = section.getTrackBlock()
703683 if (trackBlock.isInnerElement(separator)) {
704684 return trackBlock.getJoin(separator, section)
@@ -749,7 +729,6 @@ abstract class DefaultContext :
749729 nodeCell : NodeCell ,
750730 current : TrackBlock ?
751731 ): TrackBlock ? {
752- if (nodeCell == null ) throw IllegalArgumentException (" node is null" )
753732 val location = getLocation(nodeCell)
754733 val segment = getSegment(location, current)
755734 val followingSegment = nodeCell.getFollowingSegment(segment)
@@ -766,7 +745,6 @@ abstract class DefaultContext :
766745 separator : PathSeparator ,
767746 current : TrackSection ?
768747 ): TrackSection ? {
769- if (separator == null ) throw IllegalArgumentException (" separator is null" )
770748 var trackBlock: TrackBlock ? = null
771749 if (current != null ) {
772750 trackBlock = current.getTrackBlock()
@@ -862,12 +840,10 @@ abstract class DefaultContext :
862840 next : Track ? ,
863841 previous : Track ?
864842 ): Boolean {
865- requireSimulation(separator != null ) { " Separator cannot be null in isSeparatorInDirection" }
866843 val segment = getSegment(separator, next, previous)
867844 if (segment == null && separator is InOut ) return true
868845 requireSimulation(segment != null ) { " Segment cannot be null for separator $separator " }
869846 val direction = separator.direction()
870- requireSimulation(direction != null ) { " Direction cannot be null for oriented separator" }
871847 val inDirection = segment == = direction
872848 logger.debug {
873849 " isSeparatorInDirection: separator $separator , segment=$segment , direction=$direction , result=$inDirection "
@@ -882,9 +858,6 @@ abstract class DefaultContext :
882858 sep : PathSeparator ,
883859 nxt : TrackSection
884860 ): Path ? {
885- if (sep == null || nxt == null ) {
886- throw IllegalArgumentException (" wrong arguments for aPath finding" )
887- }
888861 logger.debug { " pathToNextSemaphore: searching path from $sep via track section" }
889862 var separator = sep
890863 var previous: TrackSection ? = null
@@ -940,7 +913,7 @@ abstract class DefaultContext :
940913 * Add report types to be reported
941914 */
942915 override fun addReportTypes (vararg types : ReportType ) {
943- if (types == null || types .isEmpty()) {
916+ if (types.isEmpty()) {
944917 allowedReportTypes.clear()
945918 } else {
946919 allowedReportTypes.addAll(types.asList())
@@ -956,9 +929,8 @@ abstract class DefaultContext :
956929 * Remove report types from reporting
957930 */
958931 override fun removeReportTypes (vararg types : ReportType ) {
959- if (types == null || types .isEmpty()) return
932+ if (types.isEmpty()) return
960933 for (t in types) {
961- if (t == null ) continue
962934 allowedReportTypes.remove(t)
963935 }
964936 }
0 commit comments