@Test public void testCompareTo() { ScheduledJob job1 = new ScheduledJob(); ScheduledJob job2 = new ScheduledJob(); ScheduledJob job3 = new ScheduledJob(); ScheduledJob job4 = new ScheduledJob(); ScheduledJob job5 = new ScheduledJob(); job3.setJobName( "job3" ); job4.setJobName( "job4" ); job5.setJobName( "job5" ); List<ScheduledJob> jobs = new ArrayList<> (); jobs.add( job5 ); jobs.add( job1 ); jobs.add( job3 ); jobs.add( job4 ); jobs.add( job2 ); Collections.sort( jobs ); Assert.assertEquals( job1, jobs.get( 0 )); Assert.assertEquals( job2, jobs.get( 1 )); Assert.assertEquals( job3, jobs.get( 2 )); Assert.assertEquals( job4, jobs.get( 3 )); Assert.assertEquals( job5, jobs.get( 4 )); }
@Override public int compareTo( ScheduledJob job ) { int result; if( this.jobName == null && job.jobName == null ) result = 0; else if( this.jobName == null ) result = -1; else if( job.jobName == null ) result = 1; else result = this.jobName.compareTo( job.jobName ); return result; }
ScheduledJob implements Comparable<ScheduledJob> { @Override public int compareTo( ScheduledJob job ) { int result; if( this.jobName == null && job.jobName == null ) result = 0; else if( this.jobName == null ) result = -1; else if( job.jobName == null ) result = 1; else result = this.jobName.compareTo( job.jobName ); return result; } }
ScheduledJob implements Comparable<ScheduledJob> { @Override public int compareTo( ScheduledJob job ) { int result; if( this.jobName == null && job.jobName == null ) result = 0; else if( this.jobName == null ) result = -1; else if( job.jobName == null ) result = 1; else result = this.jobName.compareTo( job.jobName ); return result; } ScheduledJob();  ScheduledJob( String jobId ); }
ScheduledJob implements Comparable<ScheduledJob> { @Override public int compareTo( ScheduledJob job ) { int result; if( this.jobName == null && job.jobName == null ) result = 0; else if( this.jobName == null ) result = -1; else if( job.jobName == null ) result = 1; else result = this.jobName.compareTo( job.jobName ); return result; } ScheduledJob();  ScheduledJob( String jobId ); void setJobId( String jobId ); String getJobId(); String getJobName(); void setJobName( String jobName ); String getAppName(); void setAppName( String appName ); String getCmdName(); void setCmdName( String cmdName ); String getCron(); void setCron( String cron ); @Override int compareTo( ScheduledJob job ); @Override boolean equals( Object obj ); @Override int hashCode(); }
ScheduledJob implements Comparable<ScheduledJob> { @Override public int compareTo( ScheduledJob job ) { int result; if( this.jobName == null && job.jobName == null ) result = 0; else if( this.jobName == null ) result = -1; else if( job.jobName == null ) result = 1; else result = this.jobName.compareTo( job.jobName ); return result; } ScheduledJob();  ScheduledJob( String jobId ); void setJobId( String jobId ); String getJobId(); String getJobName(); void setJobName( String jobName ); String getAppName(); void setAppName( String appName ); String getCmdName(); void setCmdName( String cmdName ); String getCron(); void setCron( String cron ); @Override int compareTo( ScheduledJob job ); @Override boolean equals( Object obj ); @Override int hashCode();  }