Example usage for org.apache.commons.lang ArrayUtils toPrimitive

List of usage examples for org.apache.commons.lang ArrayUtils toPrimitive

Introduction

In this page you can find the example usage for org.apache.commons.lang ArrayUtils toPrimitive.

Prototype

public static boolean[] toPrimitive(Boolean[] array) 

Source Link

Document

Converts an array of object Booleans to primitives.

Usage

From source file:mil.jpeojtrs.sca.util.tests.AnyUtilsTest.java

@Test
public void test_convertAnySequences() throws Exception {
    // Test Strings
    Object obj = null;//from   w ww  .  java 2  s .  c om
    Any theAny = JacorbUtil.init().create_any();

    final String[] stringInitialValue = new String[] { "a", "b", "c" };
    StringSeqHelper.insert(theAny, stringInitialValue);
    final String[] stringExtractedValue = StringSeqHelper.extract(theAny);
    // Sanity Check
    Assert.assertTrue(Arrays.equals(stringInitialValue, stringExtractedValue));

    // The real test
    obj = AnyUtils.convertAny(theAny);
    Assert.assertTrue(obj instanceof String[]);
    Assert.assertTrue(Arrays.equals(stringInitialValue, (String[]) obj));

    // Test Doubles
    obj = null;
    theAny = JacorbUtil.init().create_any();

    final double[] doubleInitialValue = new double[] { 0.1, 0.2, 0.3 };
    DoubleSeqHelper.insert(theAny, doubleInitialValue);
    final double[] doubleExtractedValue = DoubleSeqHelper.extract(theAny);
    // Sanity Check
    Assert.assertTrue(Arrays.equals(doubleInitialValue, doubleExtractedValue));

    // The real test
    obj = AnyUtils.convertAny(theAny);
    Assert.assertTrue(obj instanceof Double[]);
    Assert.assertTrue(Arrays.equals(ArrayUtils.toObject(doubleInitialValue), (Double[]) obj));

    // Test Integers
    obj = null;
    theAny = JacorbUtil.init().create_any();

    final int[] intInitialValue = new int[] { 1, 2, 3 };
    LongSeqHelper.insert(theAny, intInitialValue);
    final int[] intExtractedValue = LongSeqHelper.extract(theAny);
    // Sanity Check
    Assert.assertTrue(Arrays.equals(intInitialValue, intExtractedValue));

    // The real test
    obj = AnyUtils.convertAny(theAny);
    Assert.assertTrue(obj instanceof Integer[]);
    Assert.assertTrue(Arrays.equals(ArrayUtils.toObject(intInitialValue), (Integer[]) obj));

    // Test Recursive Sequence
    obj = null;
    final Any[] theAnys = new Any[2];
    theAnys[0] = JacorbUtil.init().create_any();
    theAnys[1] = JacorbUtil.init().create_any();

    LongSeqHelper.insert(theAnys[0], intInitialValue);
    LongSeqHelper.insert(theAnys[1], intInitialValue);
    AnySeqHelper.insert(theAny, theAnys);

    // The real test
    obj = AnyUtils.convertAny(theAny);
    Assert.assertTrue(obj instanceof Object[]);
    int[] extractedIntArray = ArrayUtils.toPrimitive((Integer[]) ((Object[]) obj)[0]);
    Assert.assertTrue(Arrays.equals(intInitialValue, extractedIntArray));
    extractedIntArray = ArrayUtils.toPrimitive((Integer[]) ((Object[]) obj)[1]);
    Assert.assertTrue(Arrays.equals(intInitialValue, extractedIntArray));

    String[] str = (String[]) AnyUtils
            .convertAny(AnyUtils.toAnySequence(new String[] { "2", "3" }, TCKind.tk_string));
    Assert.assertEquals("2", str[0]);
    str = (String[]) AnyUtils.convertAny(AnyUtils.toAnySequence(new String[] { "3", "4" }, TCKind.tk_wstring));
    Assert.assertEquals("3", str[0]);
    final Boolean[] bool = (Boolean[]) AnyUtils
            .convertAny(AnyUtils.toAnySequence(new boolean[] { false, true }, TCKind.tk_boolean));
    Assert.assertTrue(bool[1].booleanValue());
    final Short[] b = (Short[]) AnyUtils
            .convertAny(AnyUtils.toAnySequence(new byte[] { Byte.MIN_VALUE, Byte.MAX_VALUE }, TCKind.tk_octet));
    Assert.assertEquals(Byte.MAX_VALUE, b[1].byteValue());
    Character[] c = (Character[]) AnyUtils
            .convertAny(AnyUtils.toAnySequence(new char[] { 'r', 'h' }, TCKind.tk_char));
    Assert.assertEquals('h', c[1].charValue());
    c = (Character[]) AnyUtils
            .convertAny(AnyUtils.toAnySequence(new Character[] { '2', '3' }, TCKind.tk_wchar));
    Assert.assertEquals('2', c[0].charValue());
    final Short[] s = (Short[]) AnyUtils.convertAny(
            AnyUtils.toAnySequence(new short[] { Short.MIN_VALUE, Short.MAX_VALUE }, TCKind.tk_short));
    Assert.assertEquals(Short.MAX_VALUE, s[1].shortValue());
    final Integer[] i = (Integer[]) AnyUtils.convertAny(
            AnyUtils.toAnySequence(new int[] { Integer.MIN_VALUE, Integer.MAX_VALUE }, TCKind.tk_long));
    Assert.assertEquals(Integer.MAX_VALUE, i[1].intValue());
    final Long[] l = (Long[]) AnyUtils.convertAny(
            AnyUtils.toAnySequence(new long[] { Long.MIN_VALUE, Long.MAX_VALUE }, TCKind.tk_longlong));
    Assert.assertEquals(Long.MAX_VALUE, l[1].longValue());
    final Float[] f = (Float[]) AnyUtils.convertAny(
            AnyUtils.toAnySequence(new float[] { Float.MIN_VALUE, Float.MAX_VALUE }, TCKind.tk_float));
    Assert.assertEquals(Float.MAX_VALUE, f[1].floatValue(), 0.00001);
    final Double[] d = (Double[]) AnyUtils.convertAny(
            AnyUtils.toAnySequence(new double[] { Double.MIN_VALUE, Double.MAX_VALUE }, TCKind.tk_double));
    Assert.assertEquals(Double.MAX_VALUE, d[1].doubleValue(), 0.00001);
    final Integer[] us = (Integer[]) AnyUtils.convertAny(
            AnyUtils.toAnySequence(new short[] { Short.MIN_VALUE, Short.MAX_VALUE }, TCKind.tk_ushort));
    Assert.assertEquals(Short.MAX_VALUE, us[1].intValue());
    final Long[] ui = (Long[]) AnyUtils.convertAny(
            AnyUtils.toAnySequence(new int[] { Integer.MIN_VALUE, Integer.MAX_VALUE }, TCKind.tk_ulong));
    Assert.assertEquals(Integer.MAX_VALUE, ui[1].longValue());
    final BigInteger[] ul = (BigInteger[]) AnyUtils.convertAny(AnyUtils
            .toAnySequence(new BigInteger[] { new BigInteger("2"), new BigInteger("3") }, TCKind.tk_ulonglong));
    Assert.assertEquals(3L, ul[1].longValue());

}

From source file:com.atlassian.theplugin.idea.jira.IssueCreateDialog.java

private void addComponents(Collection<JIRAComponentBean> components) {
    final DefaultListModel listModel = new DefaultListModel();
    for (JIRAComponentBean constant : components) {
        if (constant != null && constant.getId() != CacheConstants.ANY_ID
                && constant.getId() != CacheConstants.UNKNOWN_COMPONENT_ID) {
            listModel.addElement(new ComponentWrapper(constant));
        }// w  ww.  ja va 2 s.  com
    }
    componentsList.setModel(listModel);

    if (projectComboBox.getSelectedItem() != null && jiraConfiguration != null
            && jiraConfiguration.getView() != null && jiraConfiguration.getView().getServerDefaultss() != null
            && jiraConfiguration.getView().getServerDefaultss().containsKey(jiraServerData.getServerId())) {

        String selectedProject = ((JIRAProject) projectComboBox.getSelectedItem()).getKey();

        String configProject = jiraConfiguration.getView().getServerDefaultss()
                .get(jiraServerData.getServerId()).getProject();

        Collection<Long> configComponents = jiraConfiguration.getView().getServerDefaultss()
                .get(jiraServerData.getServerId()).getComponents();

        // select default components for specified project
        if (selectedProject.equals(configProject)) {

            ArrayList<Integer> indexesToSelect = new ArrayList<Integer>(
                    componentsList.getModel().getSize() + 1);

            for (int i = 0; i < componentsList.getModel().getSize(); ++i) {
                if (componentsList.getModel().getElementAt(i) instanceof ComponentWrapper) {
                    ComponentWrapper wrapper = (ComponentWrapper) componentsList.getModel().getElementAt(i);

                    if (wrapper.getWrapped() != null) {
                        JIRAComponentBean component = wrapper.getWrapped();

                        if (configComponents.contains(component.getId())) {
                            indexesToSelect.add(i);
                        }
                    }
                }
            }

            if (indexesToSelect.size() > 0) {
                componentsList.setSelectedIndices(
                        ArrayUtils.toPrimitive(indexesToSelect.toArray(new Integer[indexesToSelect.size()])));
            }
        }
    }

    componentsList.setEnabled(true);
    getOKAction().setEnabled(true);
}

From source file:com.opengamma.analytics.financial.provider.curve.MulticurveBuildingDiscountingDiscountAUDTest.java

@Test
public void comparison1Unit2Units() {
    final MulticurveProviderDiscount[] units = new MulticurveProviderDiscount[2];
    final CurveBuildingBlockBundle[] bb = new CurveBuildingBlockBundle[2];
    final YieldAndDiscountCurve[] curveDsc = new YieldAndDiscountCurve[2];
    final YieldAndDiscountCurve[] curveFwd = new YieldAndDiscountCurve[2];
    for (int loopblock = 0; loopblock < 2; loopblock++) {
        units[loopblock] = CURVES_PAR_SPREAD_MQ_WITHOUT_TODAY_BLOCK.get(loopblock).getFirst();
        bb[loopblock] = CURVES_PAR_SPREAD_MQ_WITHOUT_TODAY_BLOCK.get(loopblock).getSecond();
        curveDsc[loopblock] = units[loopblock].getCurve(AUD);
        curveFwd[loopblock] = units[loopblock].getCurve(AUDBB3M);
    }/*from w w w .  ja  v a  2  s.  c o m*/
    assertEquals("Curve construction: 1 unit / 2 units ", curveDsc[0].getNumberOfParameters(),
            curveDsc[1].getNumberOfParameters());
    assertEquals("Curve construction: 1 unit / 2 units ", curveFwd[0].getNumberOfParameters(),
            curveFwd[1].getNumberOfParameters());
    assertArrayEquals("Curve construction: 1 unit / 2 units ",
            ArrayUtils.toPrimitive(((YieldCurve) curveDsc[0]).getCurve().getXData()),
            ArrayUtils.toPrimitive(((YieldCurve) curveDsc[1]).getCurve().getXData()), TOLERANCE_CAL);
    assertArrayEquals("Curve construction: 1 unit / 2 units ",
            ArrayUtils.toPrimitive(((YieldCurve) curveDsc[0]).getCurve().getYData()),
            ArrayUtils.toPrimitive(((YieldCurve) curveDsc[1]).getCurve().getYData()), TOLERANCE_CAL);
    assertArrayEquals("Curve construction: 1 unit / 2 units ",
            ArrayUtils.toPrimitive(((YieldCurve) curveFwd[0]).getCurve().getXData()),
            ArrayUtils.toPrimitive(((YieldCurve) curveFwd[1]).getCurve().getXData()), TOLERANCE_CAL);
    assertArrayEquals("Curve construction: 1 unit / 2 units ",
            ArrayUtils.toPrimitive(((YieldCurve) curveFwd[0]).getCurve().getYData()),
            ArrayUtils.toPrimitive(((YieldCurve) curveFwd[1]).getCurve().getYData()), TOLERANCE_CAL);

    assertEquals("Curve construction: 1 unit / 2 units ", bb[0].getBlock(CURVE_NAME_FWD3_AUD).getFirst(),
            bb[1].getBlock(CURVE_NAME_FWD3_AUD).getFirst());
    // Test note: the discounting curve building blocks are not the same; in one case both curves are build together in the other one after the other.
    final int nbLineDsc = bb[0].getBlock(CURVE_NAME_DSC_AUD).getSecond().getNumberOfRows();
    final int nbLineFwd3 = bb[0].getBlock(CURVE_NAME_FWD3_AUD).getSecond().getNumberOfRows();
    final int nbLineFwd6 = bb[0].getBlock(CURVE_NAME_FWD6_AUD).getSecond().getNumberOfRows();
    assertEquals("Curve construction: 1 unit / 2 units ",
            bb[1].getBlock(CURVE_NAME_DSC_AUD).getSecond().getNumberOfRows(), nbLineDsc);
    assertEquals("Curve construction: 1 unit / 2 units ",
            bb[1].getBlock(CURVE_NAME_FWD3_AUD).getSecond().getNumberOfRows(), nbLineFwd3);
    assertEquals("Curve construction: 1 unit / 2 units ",
            bb[1].getBlock(CURVE_NAME_FWD6_AUD).getSecond().getNumberOfRows(), nbLineFwd6);
}

From source file:com.opengamma.analytics.financial.provider.curve.MulticurveBuildingDiscountingDiscountEURCommitteeTest.java

@Test(enabled = false)
public void comparison1Unit2Units() {
    final MulticurveProviderDiscount[] units = new MulticurveProviderDiscount[2];
    final CurveBuildingBlockBundle[] bb = new CurveBuildingBlockBundle[2];
    final YieldAndDiscountCurve[] curveDsc = new YieldAndDiscountCurve[2];
    final YieldAndDiscountCurve[] curveFwd3 = new YieldAndDiscountCurve[2];
    final YieldAndDiscountCurve[] curveFwd6 = new YieldAndDiscountCurve[2];
    for (int loopblock = 0; loopblock < 2; loopblock++) {
        units[loopblock] = CURVES_PAR_SPREAD_MQ_WITHOUT_TODAY_BLOCK.get(loopblock).getFirst();
        bb[loopblock] = CURVES_PAR_SPREAD_MQ_WITHOUT_TODAY_BLOCK.get(loopblock).getSecond();
        curveDsc[loopblock] = units[loopblock].getCurve(EUR);
        curveFwd6[loopblock] = units[loopblock].getCurve(EURIBOR6M);
    }/* w w  w .j  a v a  2 s .  co  m*/
    assertEquals("Curve construction: 1 unit / 3 units ", curveDsc[0].getNumberOfParameters(),
            curveDsc[1].getNumberOfParameters());
    assertEquals("Curve construction: 1 unit / 3 units ", curveFwd3[0].getNumberOfParameters(),
            curveFwd3[1].getNumberOfParameters());
    assertEquals("Curve construction: 1 unit / 3 units ", curveFwd6[0].getNumberOfParameters(),
            curveFwd6[1].getNumberOfParameters());
    assertArrayEquals("Curve construction: 1 unit / 3 units ",
            ArrayUtils.toPrimitive(((YieldCurve) curveDsc[0]).getCurve().getXData()),
            ArrayUtils.toPrimitive(((YieldCurve) curveDsc[1]).getCurve().getXData()), TOLERANCE_CAL);
    assertArrayEquals("Curve construction: 1 unit / 3 units ",
            ArrayUtils.toPrimitive(((YieldCurve) curveDsc[0]).getCurve().getYData()),
            ArrayUtils.toPrimitive(((YieldCurve) curveDsc[1]).getCurve().getYData()), TOLERANCE_CAL);
    assertArrayEquals("Curve construction: 1 unit / 3 units ",
            ArrayUtils.toPrimitive(((YieldCurve) curveFwd3[0]).getCurve().getXData()),
            ArrayUtils.toPrimitive(((YieldCurve) curveFwd3[1]).getCurve().getXData()), TOLERANCE_CAL);
    assertArrayEquals("Curve construction: 1 unit / 3 units ",
            ArrayUtils.toPrimitive(((YieldCurve) curveFwd3[0]).getCurve().getYData()),
            ArrayUtils.toPrimitive(((YieldCurve) curveFwd3[1]).getCurve().getYData()), TOLERANCE_CAL);
    assertArrayEquals("Curve construction: 1 unit / 3 units ",
            ArrayUtils.toPrimitive(((YieldCurve) curveFwd6[0]).getCurve().getXData()),
            ArrayUtils.toPrimitive(((YieldCurve) curveFwd6[1]).getCurve().getXData()), TOLERANCE_CAL);
    assertArrayEquals("Curve construction: 1 unit / 3 units ",
            ArrayUtils.toPrimitive(((YieldCurve) curveFwd6[0]).getCurve().getYData()),
            ArrayUtils.toPrimitive(((YieldCurve) curveFwd6[1]).getCurve().getYData()), TOLERANCE_CAL);

    assertEquals("Curve construction: 1 unit / 3 units ", bb[0].getBlock(CURVE_NAME_FWD6_EUR).getFirst(),
            bb[1].getBlock(CURVE_NAME_FWD6_EUR).getFirst());
}

From source file:com.stoxx.service.business.registration.RegistrationServiceImpl.java

@Override
public User saveUserToLiferayDBForTranslator(UserProfileDetails userProfileDetails, ThemeDisplay themeDisplay,
        ServiceContext serviceContext, TranslatorAgency translatorAgency) throws STOXXException {
    try {//  ww  w .j a v a  2  s . c om
        Group stoxxNetgroup = GroupLocalServiceUtil.getGroup(themeDisplay.getCompanyId(),
                STOXXConstants.STOXXNET_SITE_NAME);
        User adminDefaultUser = UserLocalServiceUtil.getDefaultUser(themeDisplay.getCompanyId());
        logger.info("the ****************************>default user id is " + adminDefaultUser.getUserId()
                + EMAIL_ADDRESS_IS + adminDefaultUser.getEmailAddresses());
        long[] groupIds = null;
        if (userProfileDetails.getUserType().equalsIgnoreCase(STOXXConstants.STOXX_VENDOR_USER)) {
            groupIds = new long[] { stoxxNetgroup.getGroupId() };
        }
        User user = null;
        if (userProfileDetails.getUserType().equalsIgnoreCase(STOXXConstants.STOXX_VENDOR_USER)) {
            StringBuilder userGroupNameTemp = new StringBuilder();
            String userGroupName = StringPool.BLANK;
            List<Long> translatorRoles = null;
            if (translatorAgency.getCompanyName().trim().contains(StringPool.SPACE)) {

                for (String word : translatorAgency.getCompanyName().trim().split(StringPool.SPACE)) {
                    userGroupNameTemp.append(word).append(StringPool.UNDERLINE);
                }
                userGroupName = userGroupNameTemp.substring(0, userGroupNameTemp.length() - 1);
                translatorRoles = assignTranslatorRole(userGroupName, translatorAgency, themeDisplay);
            } else {
                userGroupName = translatorAgency.getCompanyName().trim();
                translatorRoles = assignTranslatorRole(userGroupName, translatorAgency, themeDisplay);
            }
            UserGroup translatorGroup = UserGroupLocalServiceUtil.getUserGroup(themeDisplay.getCompanyId(),
                    userGroupName);
            long translatorGroupId[] = { translatorGroup.getUserGroupId() };
            long translatorRoleId[] = ArrayUtils
                    .toPrimitive(translatorRoles.toArray(new Long[translatorRoles.size()]));
            if (translatorAgency.getAgencyManagerEmailId()
                    .equalsIgnoreCase(userProfileDetails.getEmailAddress())) {
                user = UserLocalServiceUtil.addUser(adminDefaultUser.getUserId(), themeDisplay.getCompanyId(),
                        false, userProfileDetails.getPassword(), userProfileDetails.getPassword(), true,
                        StringPool.BLANK, userProfileDetails.getEmailAddress(), 0, StringPool.BLANK,
                        themeDisplay.getLocale(), userProfileDetails.getFirstName(), StringPool.BLANK,
                        userProfileDetails.getLastName(), userProfileDetails.getPrefixId(), 0,
                        userProfileDetails.isGender(), userProfileDetails.getBirthMonth(),
                        userProfileDetails.getBirthDay(), userProfileDetails.getBirthYear(),
                        userProfileDetails.getJobTitle(), groupIds, null, translatorRoleId, translatorGroupId,
                        false, serviceContext);
            } else {
                user = UserLocalServiceUtil.addUser(adminDefaultUser.getUserId(), themeDisplay.getCompanyId(),
                        false, userProfileDetails.getPassword(), userProfileDetails.getPassword(), true,
                        StringPool.BLANK, userProfileDetails.getEmailAddress(), 0, StringPool.BLANK,
                        themeDisplay.getLocale(), userProfileDetails.getFirstName(), StringPool.BLANK,
                        userProfileDetails.getLastName(), userProfileDetails.getPrefixId(), 0,
                        userProfileDetails.isGender(), userProfileDetails.getBirthMonth(),
                        userProfileDetails.getBirthDay(), userProfileDetails.getBirthYear(),
                        userProfileDetails.getJobTitle(), groupIds, null, null, translatorGroupId, false,
                        serviceContext);
            }
        }
        Role powerUserRole = RoleLocalServiceUtil.getRole(themeDisplay.getCompanyId(),
                RoleConstants.POWER_USER);
        if (Validator.isNotNull(powerUserRole)) {
            long rolePower[] = { powerUserRole.getRoleId() };
            if (Validator.isNotNull(user) && rolePower.length > 0) {
                RoleLocalServiceUtil.unsetUserRoles(user.getUserId(), rolePower);
            }
        }

        return user;
    } catch (PortalException e) {
        logger.error(e.getMessage(), e);
        throw new STOXXException(e.getMessage(), e);
    } catch (SystemException e) {
        logger.error(e.getMessage(), e);
        throw new STOXXException(e.getMessage(), e);
    }
}

From source file:com.opengamma.analytics.financial.provider.curve.MulticurveBuildingDiscountingDiscountEURCommittee2Test.java

@Test(enabled = false)
public void comparison1Unit3Units() {
    final MulticurveProviderDiscount[] units = new MulticurveProviderDiscount[2];
    final CurveBuildingBlockBundle[] bb = new CurveBuildingBlockBundle[2];
    final YieldAndDiscountCurve[] curveDsc = new YieldAndDiscountCurve[2];
    final YieldAndDiscountCurve[] curveFwd3 = new YieldAndDiscountCurve[2];
    final YieldAndDiscountCurve[] curveFwd6 = new YieldAndDiscountCurve[2];
    for (int loopblock = 0; loopblock < 2; loopblock++) {
        units[loopblock] = CURVES_PAR_SPREAD_MQ_WITHOUT_TODAY_BLOCK.get(loopblock).getFirst();
        bb[loopblock] = CURVES_PAR_SPREAD_MQ_WITHOUT_TODAY_BLOCK.get(loopblock).getSecond();
        curveDsc[loopblock] = units[loopblock].getCurve(EUR);
        curveFwd6[loopblock] = units[loopblock].getCurve(EURIBOR6M);
    }//from  w ww  .ja va  2 s.  c o m
    assertEquals("Curve construction: 1 unit / 3 units ", curveDsc[0].getNumberOfParameters(),
            curveDsc[1].getNumberOfParameters());
    assertEquals("Curve construction: 1 unit / 3 units ", curveFwd3[0].getNumberOfParameters(),
            curveFwd3[1].getNumberOfParameters());
    assertEquals("Curve construction: 1 unit / 3 units ", curveFwd6[0].getNumberOfParameters(),
            curveFwd6[1].getNumberOfParameters());
    assertArrayEquals("Curve construction: 1 unit / 3 units ",
            ArrayUtils.toPrimitive(((YieldCurve) curveDsc[0]).getCurve().getXData()),
            ArrayUtils.toPrimitive(((YieldCurve) curveDsc[1]).getCurve().getXData()), TOLERANCE_CAL);
    assertArrayEquals("Curve construction: 1 unit / 3 units ",
            ArrayUtils.toPrimitive(((YieldCurve) curveDsc[0]).getCurve().getYData()),
            ArrayUtils.toPrimitive(((YieldCurve) curveDsc[1]).getCurve().getYData()), TOLERANCE_CAL);
    assertArrayEquals("Curve construction: 1 unit / 3 units ",
            ArrayUtils.toPrimitive(((YieldCurve) curveFwd3[0]).getCurve().getXData()),
            ArrayUtils.toPrimitive(((YieldCurve) curveFwd3[1]).getCurve().getXData()), TOLERANCE_CAL);
    assertArrayEquals("Curve construction: 1 unit / 3 units ",
            ArrayUtils.toPrimitive(((YieldCurve) curveFwd3[0]).getCurve().getYData()),
            ArrayUtils.toPrimitive(((YieldCurve) curveFwd3[1]).getCurve().getYData()), TOLERANCE_CAL);
    assertArrayEquals("Curve construction: 1 unit / 3 units ",
            ArrayUtils.toPrimitive(((YieldCurve) curveFwd6[0]).getCurve().getXData()),
            ArrayUtils.toPrimitive(((YieldCurve) curveFwd6[1]).getCurve().getXData()), TOLERANCE_CAL);
    assertArrayEquals("Curve construction: 1 unit / 3 units ",
            ArrayUtils.toPrimitive(((YieldCurve) curveFwd6[0]).getCurve().getYData()),
            ArrayUtils.toPrimitive(((YieldCurve) curveFwd6[1]).getCurve().getYData()), TOLERANCE_CAL);

    assertEquals("Curve construction: 1 unit / 3 units ", bb[0].getBlock(CURVE_NAME_FWD6_EUR).getFirst(),
            bb[1].getBlock(CURVE_NAME_FWD6_EUR).getFirst());
}

From source file:com.opengamma.analytics.financial.provider.curve.MulticurveBuildingHullWhiteDiscountFuturesEUR3Test.java

@Test(enabled = false)
public void comparison1Unit3Units() {
    final HullWhiteOneFactorProviderDiscount[] units = new HullWhiteOneFactorProviderDiscount[2];
    final CurveBuildingBlockBundle[] bb = new CurveBuildingBlockBundle[2];
    final YieldAndDiscountCurve[] curveDsc = new YieldAndDiscountCurve[2];
    final YieldAndDiscountCurve[] curveFwd3 = new YieldAndDiscountCurve[2];
    final YieldAndDiscountCurve[] curveFwd6 = new YieldAndDiscountCurve[2];
    for (int loopblock = 0; loopblock < 2; loopblock++) {
        units[loopblock] = CURVES_PAR_SPREAD_MQ_WITHOUT_TODAY_BLOCK.get(loopblock).getFirst();
        bb[loopblock] = CURVES_PAR_SPREAD_MQ_WITHOUT_TODAY_BLOCK.get(loopblock).getSecond();
        curveDsc[loopblock] = units[loopblock].getCurve(EUR);
        curveFwd3[loopblock] = units[loopblock].getCurve(EURIBOR3M);
        curveFwd6[loopblock] = units[loopblock].getCurve(EURIBOR6M);
    }/*  w ww .  j  ava 2s  .c o  m*/
    assertEquals("Curve construction: 1 unit / 3 units ", curveDsc[0].getNumberOfParameters(),
            curveDsc[1].getNumberOfParameters());
    assertEquals("Curve construction: 1 unit / 3 units ", curveFwd3[0].getNumberOfParameters(),
            curveFwd3[1].getNumberOfParameters());
    assertEquals("Curve construction: 1 unit / 3 units ", curveFwd6[0].getNumberOfParameters(),
            curveFwd6[1].getNumberOfParameters());
    assertArrayEquals("Curve construction: 1 unit / 3 units ",
            ArrayUtils.toPrimitive(((YieldCurve) curveDsc[0]).getCurve().getXData()),
            ArrayUtils.toPrimitive(((YieldCurve) curveDsc[1]).getCurve().getXData()), TOLERANCE_CAL);
    assertArrayEquals("Curve construction: 1 unit / 3 units ",
            ArrayUtils.toPrimitive(((YieldCurve) curveDsc[0]).getCurve().getYData()),
            ArrayUtils.toPrimitive(((YieldCurve) curveDsc[1]).getCurve().getYData()), TOLERANCE_CAL);
    assertArrayEquals("Curve construction: 1 unit / 3 units ",
            ArrayUtils.toPrimitive(((YieldCurve) curveFwd3[0]).getCurve().getXData()),
            ArrayUtils.toPrimitive(((YieldCurve) curveFwd3[1]).getCurve().getXData()), TOLERANCE_CAL);
    assertArrayEquals("Curve construction: 1 unit / 3 units ",
            ArrayUtils.toPrimitive(((YieldCurve) curveFwd3[0]).getCurve().getYData()),
            ArrayUtils.toPrimitive(((YieldCurve) curveFwd3[1]).getCurve().getYData()), TOLERANCE_CAL);
    assertArrayEquals("Curve construction: 1 unit / 3 units ",
            ArrayUtils.toPrimitive(((YieldCurve) curveFwd6[0]).getCurve().getXData()),
            ArrayUtils.toPrimitive(((YieldCurve) curveFwd6[1]).getCurve().getXData()), TOLERANCE_CAL);
    assertArrayEquals("Curve construction: 1 unit / 3 units ",
            ArrayUtils.toPrimitive(((YieldCurve) curveFwd6[0]).getCurve().getYData()),
            ArrayUtils.toPrimitive(((YieldCurve) curveFwd6[1]).getCurve().getYData()), TOLERANCE_CAL);

    assertEquals("Curve construction: 1 unit / 3 units ", bb[0].getBlock(CURVE_NAME_FWD6_EUR).getFirst(),
            bb[1].getBlock(CURVE_NAME_FWD6_EUR).getFirst());
}

From source file:be.ugent.maf.cellmissy.gui.controller.analysis.singlecell.SingleCellAnalysisController.java

/**
 * For a single well, generate an histogram dataset.
 *
 * @param data//w w w  .j a  v  a  2s  .  co  m
 * @param seriesKey
 * @param mapTo360
 * @return an HistogramDataset
 */
private HistogramDataset getHistogramDatasetForACondition(
        SingleCellConditionDataHolder singleCellConditionDataHolder, String seriesKey, int bins) {
    HistogramDataset dataset = new HistogramDataset();
    dataset.setType(HistogramType.RELATIVE_FREQUENCY);
    double[] toPrimitive = ArrayUtils.toPrimitive(
            AnalysisUtils.excludeNullValues(singleCellConditionDataHolder.getTurningAnglesVector()));

    double[] mappedData = new double[toPrimitive.length];
    for (int i = 0; i < toPrimitive.length; i++) {
        if (toPrimitive[i] > 0) {
            mappedData[i] = toPrimitive[i];
        } else {
            mappedData[i] = toPrimitive[i] + 360;
        }
    }
    double[] toAdd = mappedData;

    dataset.addSeries(seriesKey, toAdd, bins);
    return dataset;
}

From source file:ch.algotrader.esper.EngineImpl.java

@Override
public void addFirstTickCallback(Collection<Long> securityIds, BiConsumer<String, List<TickVO>> consumer) {

    Validate.notEmpty(securityIds, "orderIntIds is empty");

    String alias = "ON_FIRST_TICK_" + StringUtils.join(securityIds, "_");

    if (isDeployed(alias)) {

        if (LOGGER.isWarnEnabled()) {
            LOGGER.warn("{} is already deployed", alias);
        }//  w w w. j a v a2 s  .  com
    } else {

        long[] securityIdsArray = ArrayUtils.toPrimitive(securityIds.toArray(new Long[0]));
        deployStatement("prepared", "ON_FIRST_TICK", alias,
                new Object[] { securityIds.size(), securityIdsArray }, new TickCallback(this, alias, consumer));
    }
}

From source file:com.flexive.war.beans.admin.main.AccountBean.java

/**
 * Action method to save the user settings
 * /*from   www  .jav  a  2s. c o  m*/
 * @return edit user page
 */
public String saveUser() {
    try {
        String newPasswd = null;

        // check if the old password was entered correctly (only upon setting a new one)
        if (isShowOldPassword() && (password != null && password.trim().length() > 0)) {
            try {
                if (StringUtils.isBlank(oldPassword) || !getAccountEngine().loginCheck(account.getName(),
                        oldPassword, FxJsfUtils.getRequest().getUserTicket())) {
                    new FxFacesMsgErr("User.err.noOldPasswordMatch").addToContext();
                    return "accountEdit";
                }
            } catch (FxLoginFailedException e) {
                new FxFacesMsgErr("User.err.settingsNotSaved").addToContext();
                new FxFacesMsgErr(e).addToContext();
                return "accountEdit";
            }
        }

        // Determine if the password must be set
        if (password != null && password.trim().length() > 0) {
            if (!password.equals(passwordConfirm)) {
                new FxFacesMsgErr("User.err.passwordsDontMatch").addToContext();
                return "accountEdit";
            }
            newPasswd = password;
        }

        // Update the user
        getAccountEngine().update(this.accountIdFilter, newPasswd, null, null, null, this.account.getEmail(),
                this.account.isValidated(), this.account.isActive(), this.account.getValidFrom(),
                this.account.getValidTo(), this.account.getLanguage().getId(), this.account.getDescription(),
                this.account.isAllowMultiLogin(), this.account.getContactData().getId());
        new FxFacesMsgInfo("User.nfo.saved").addToContext();
        // Assign the given groups to the account
        try {
            getAccountEngine().setGroups(this.accountIdFilter, ArrayUtils.toPrimitive(this.groups));
        } catch (Exception exc) {
            new FxFacesMsgErr(exc).addToContext();
        }

        // Assign the given roles to the account
        try {
            getAccountEngine().setRoles(this.accountIdFilter, getRoles());
        } catch (Exception exc) {
            new FxFacesMsgErr(exc).addToContext();
        }
        // Reload and display
        return editUser();
    } catch (Throwable t) {
        new FxFacesMsgErr(t).addToContext();
        return "accountEdit";
    }
}