MCPcopy Create free account
hub / github.com/PCGen/pcgen / compare

Method compare

code/src/java/pcgen/core/DataSet.java:507–561  ·  view source on GitHub ↗
(PCClass c1, PCClass c2)

Source from the content-addressed store, hash-verified

505 {
506
507 @Override
508 public int compare(PCClass c1, PCClass c2)
509 {
510 final int BEFORE = -1;
511 final int AFTER = 1;
512
513 if (c1 == c2)
514 {
515 return 0;
516 }
517
518 final String BASE_TYPE = "BASE.PC";
519 if (c1.isType(BASE_TYPE) && !c2.isType(BASE_TYPE))
520 {
521 return BEFORE;
522 }
523 if (!c1.isType(BASE_TYPE) && c2.isType(BASE_TYPE))
524 {
525 return AFTER;
526 }
527
528 final String PRESTIGE_TYPE = "Prestige";
529 if (c1.isType(PRESTIGE_TYPE) && !c2.isType(PRESTIGE_TYPE))
530 {
531 return BEFORE;
532 }
533 if (!c1.isType(PRESTIGE_TYPE) && c2.isType(PRESTIGE_TYPE))
534 {
535 return AFTER;
536 }
537
538 final String NPC_TYPE = "NPC";
539 if (c1.isType(NPC_TYPE) && !c2.isType(NPC_TYPE))
540 {
541 return BEFORE;
542 }
543 if (!c1.isType(NPC_TYPE) && c2.isType(NPC_TYPE))
544 {
545 return AFTER;
546 }
547
548 // Check sort keys
549 String key1 = c1.get(StringKey.SORT_KEY);
550 if (key1 == null)
551 {
552 key1 = c1.getDisplayName();
553 }
554 String key2 = c2.get(StringKey.SORT_KEY);
555 if (key2 == null)
556 {
557 key2 = c2.getDisplayName();
558 }
559 final Collator collator = Collator.getInstance();
560 return collator.compare(key1, key2);
561 }
562
563 }
564

Callers

nothing calls this directly

Calls 5

isTypeMethod · 0.65
getMethod · 0.65
getDisplayNameMethod · 0.65
getInstanceMethod · 0.45
compareMethod · 0.45

Tested by

no test coverage detected