private BusinessId(EntityType entityType, IdType idType, TaxId entityId) { this.entityType = entityType; this.idType = idType; this.entityId = entityId; value = idType + SEPARATOR + entityType.GetValue() + SEPARATOR + entityId.GetValue(); }
/** * Kreira objekat tako što parsira prosledjen String.<br> * Očekuje se da prosledjeni String bude oblika "idType#entityType#idValue" (gde je znakom # označen sistemski separator među ovim podacima). Unutar vrednosti idType i entityType * se ne može naći znak separator, ali je sasvim moguće da se unutar idValue nalazi jedan ili više takvih znakova. Zato se parsiranje ne vrši preko String.split, nego "manuelno".<br> * @param value String oblika "idType#entityType#idValue" * @throws DataInstantiationException */ public BusinessId(String value) { this.value = value; string handyString = value; int index = handyString.IndexOf(SEPARATOR); if (index < 1) { throw CreateException("BusinessId(" + value + "). No separator"); } idType = (IdType)Enum.Parse(typeof(IdType), handyString.Substring(0, index)); if (idType == null) { throw CreateException("BusinessId(" + value + "). Wrong IdType"); } handyString = handyString.Substring(index + 1); index = handyString.IndexOf(SEPARATOR); if (index < 1) { throw CreateException("BusinessId(" + value + "). No second separator"); } entityType = new EntityType(handyString.Substring(0, index)); entityId = new TaxId(handyString.Substring(index + 1)); }
public static bool IsEmpty(TaxId id) { return(id == null || id.value.Trim().Equals("0")); }