public static OutputDefinition findSingleByName ( final Collection<OutputDefinition> defs, final String name ) { for ( final OutputDefinition def : defs ) { if ( name.equals ( def.getName () ) ) { return def; } } throw new IllegalArgumentException ( String.format ( "Unable to find an output named '%s'", name ) ); }
public static OutputSpecification findSpecification ( final CalculationModule implementation, final OutputDefinition output ) { for ( final OutputSpecification spec : implementation.getKnownOutputs () ) { if ( spec.getName () != null && spec.getName ().equals ( output.getName () ) ) { return spec; } } return null; }
/** * This returns the label styled text for the adapted class. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public Object getStyledText ( Object object ) { String label = ( (OutputDefinition)object ).getName (); StyledString styledLabel = new StyledString (); if ( label == null || label.length () == 0 ) { styledLabel.append ( getString ( "_UI_OutputDefinition_type" ), StyledString.Style.QUALIFIER_STYLER ); //$NON-NLS-1$ } else { styledLabel.append ( getString ( "_UI_OutputDefinition_type" ), StyledString.Style.QUALIFIER_STYLER ).append ( " " + label ); //$NON-NLS-1$ //$NON-NLS-2$ } return styledLabel; }
/** * This returns the label styled text for the adapted class. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public Object getStyledText ( Object object ) { String label = ( (OutputDefinition)object ).getName (); StyledString styledLabel = new StyledString (); if ( label == null || label.length () == 0 ) { styledLabel.append ( getString ( "_UI_OutputDefinition_type" ), StyledString.Style.QUALIFIER_STYLER ); //$NON-NLS-1$ } else { styledLabel.append ( getString ( "_UI_OutputDefinition_type" ), StyledString.Style.QUALIFIER_STYLER ).append ( " " + label ); //$NON-NLS-1$ //$NON-NLS-2$ } return styledLabel; }
@Override public void createItems ( final ItemCreator creator, final MovingAverageModule implementation ) { for ( final OutputDefinition output : this.calculationComponent.getOutputs () ) { final OutputSpecification outputSpec = Calculations.findSpecification ( implementation, output ); final MovingAverageReferenceType type = MovingAverageReferenceType.get ( output.getName () ); if ( type == null ) { throw new IllegalStateException ( String.format ( "Moving average reference type %s is unknown. Use any of: %s.", output.getName (), StringHelper.join ( MovingAverageReferenceType.values (), ", " ) ) ); } final CreationRequest<MovingAverageItem> c = createAverageItem ( creator, type ); c.localTags ( output.getLocalTag () ); c.customizationTags ( output.getCustomizationTags () );// the output of a calculation module is an input for the system c.dataType ( outputSpec.getDataType () ); c.addMasterListener ( new MasterListener<MovingAverageItem> () { @Override public void setMaster ( final MovingAverageItem item, final MasterContext master ) { final MovingAverage average = MovingAverageModuleGenerator.this.map.get ( master.getImplementation () ); item.setSource ( average ); } } ); c.create (); } }
@Override public void createItems ( final ItemCreator creator, final AverageModule implementation ) { for ( final OutputDefinition output : this.calculationComponent.getOutputs () ) { final OutputSpecification outputSpec = Calculations.findSpecification ( implementation, output ); final AverageReferenceType type = AverageReferenceType.get ( output.getName () ); if ( type == null ) { throw new IllegalStateException ( String.format ( "Average reference type %s is unknown. Use any of: %s.", output.getName (), StringHelper.join ( AverageReferenceType.values (), ", " ) ) ); } final CreationRequest<AverageItem> c = createAverageItem ( creator, type ); c.localTags ( output.getLocalTag () ); c.customizationTags ( output.getCustomizationTags () );// the output of a calculation module is an input for the system c.dataType ( outputSpec.getDataType () ); c.addMasterListener ( new MasterListener<AverageItem> () { @Override public void setMaster ( final AverageItem item, final MasterContext master ) { final Average average = AverageModuleGenerator.this.map.get ( master.getImplementation () ); item.setSource ( average ); } } ); c.create (); } }
throw new IllegalStateException ( String.format ( "Output specification '%s' not found on module '%s'", output.getName (), implementation.getName () ) );