BasePropertySource implements PropertySource { public int getOrdinal() { Integer ordinal = this.ordinal; if(ordinal!=null){ Logger.getLogger(getClass().getName()).finest( "Using explicit ordinal '"+ordinal+"' for property source: " + getName()); return ordinal; } PropertyValue configuredOrdinal = get(TAMAYA_ORDINAL); if(configuredOrdinal!=null){ try { return Double.valueOf(configuredOrdinal.getValue()).intValue(); } catch (Exception e) { Logger.getLogger(getClass().getName()).log(Level.WARNING, "Configured ordinal is not an int number: " + configuredOrdinal, e); } } return getDefaultOrdinal(); } protected  BasePropertySource(String name); protected  BasePropertySource(int defaultOrdinal); protected  BasePropertySource(String name, int defaultOrdinal); protected  BasePropertySource(); @Override String getName(); void setName(String name); void setOrdinal(Integer ordinal); void setDefaultOrdinal(Integer defaultOrdinal); int getOrdinal(); int getDefaultOrdinal(); @Override PropertyValue get(String key); boolean isDisabled(); void setDisabled(boolean disabled); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); @Override ChangeSupport getChangeSupport(); PropertySource setChangeSupport(ChangeSupport changeSupport);  }
@Test public void testGetOrdinal() { PropertySource defaultPropertySource = new BasePropertySource(56) { @Override public String getName() { return "testWithDefault"; } @Override public PropertyValue get(String key) { return null; } @Override public Map<String, PropertyValue> getProperties() { return Collections.emptyMap(); } }; assertThat(PropertySourceComparator.getOrdinal(defaultPropertySource)).isEqualTo(56); assertThat(new OverriddenOrdinalPropertySource().getOrdinal()).isEqualTo(1000); assertThat(new OverriddenInvalidOrdinalPropertySource().getOrdinal()).isEqualTo(1); }