/** * Restricted copy constructor. * @param beanToCopy the bean to copy from, not null */ private Builder(EtdOptionPosition beanToCopy) { this.info = beanToCopy.getInfo(); this.security = beanToCopy.getSecurity(); this.longQuantity = beanToCopy.getLongQuantity(); this.shortQuantity = beanToCopy.getShortQuantity(); }
@Override public SecuritizedProductPosition<?> resolveTarget(ReferenceData refData) { SecurityId securityId = getSecurityId(); Security security = refData.getValue(securityId); Position position = security.createPosition(getInfo(), getLongQuantity(), getShortQuantity(), refData); if (position instanceof SecuritizedProductPosition) { return (SecuritizedProductPosition<?>) position; } throw new ClassCastException(Messages.format( "Reference data for security '{}' did not implement SecuritizedProductPosition: ", securityId, position.getClass().getName())); }
@Override protected Object propertyGet(Bean bean, String propertyName, boolean quiet) { switch (propertyName.hashCode()) { case 3237038: // info return ((EtdOptionPosition) bean).getInfo(); case 949122880: // security return ((EtdOptionPosition) bean).getSecurity(); case 611668775: // longQuantity return ((EtdOptionPosition) bean).getLongQuantity(); case -2094395097: // shortQuantity return ((EtdOptionPosition) bean).getShortQuantity(); case -1285004149: // quantity return ((EtdOptionPosition) bean).getQuantity(); } return super.propertyGet(bean, propertyName, quiet); }
public void test_ofNet_withInfo() { EtdOptionPosition test = EtdOptionPosition.ofNet(POSITION_INFO, SECURITY, 1000); assertEquals(test.getLongQuantity(), 1000d, 0d); assertEquals(test.getShortQuantity(), 0d, 0d); assertEquals(test.getInfo(), POSITION_INFO); assertEquals(test.getSecurity(), SECURITY); assertEquals(test.getQuantity(), 1000d, 0d); }
public void test_ofLongShort_withInfo() { EtdOptionPosition test = EtdOptionPosition.ofLongShort(POSITION_INFO, SECURITY, 2000, 1000); assertEquals(test.getLongQuantity(), 2000d, 0d); assertEquals(test.getShortQuantity(), 1000d, 0d); assertEquals(test.getInfo(), POSITION_INFO); assertEquals(test.getSecurity(), SECURITY); assertEquals(test.getQuantity(), 1000d, 0d); }
public void test_ofNet() { EtdOptionPosition test = EtdOptionPosition.ofNet(SECURITY, 1000); assertEquals(test.getLongQuantity(), 1000d, 0d); assertEquals(test.getShortQuantity(), 0d, 0d); assertEquals(test.getSecurity(), SECURITY); assertEquals(test.getQuantity(), 1000d, 0d); assertEquals(test.withInfo(POSITION_INFO).getInfo(), POSITION_INFO); assertEquals(test.withQuantity(129).getQuantity(), 129d, 0d); assertEquals(test.withQuantity(-129).getQuantity(), -129d, 0d); }