Example usage for org.apache.commons.lang StringUtils swapCase

List of usage examples for org.apache.commons.lang StringUtils swapCase

Introduction

In this page you can find the example usage for org.apache.commons.lang StringUtils swapCase.

Prototype

public static String swapCase(String str) 

Source Link

Document

Swaps the case of a String changing upper and title case to lower case, and lower case to upper case.

Usage

From source file:br.com.renatoccosta.regexrenamer.element.CaseElement.java

@Override
protected String convert(String src) {
    switch (mode) {
    case UPPER:/*from  www.  j a  va 2s.c o m*/
        return src.toUpperCase();
    case LOWER:
        return src.toLowerCase();
    case SWAP:
        return StringUtils.swapCase(src);
    }

    return src;
}

From source file:ninja.text.TextImpl.java

@Override
public Text swapCase() {
    return Text.of(StringUtils.swapCase(data.toString()));
}

From source file:org.fao.geonet.api.users.UsersApiTest.java

@Test
public void updateUserDuplicatedUsernameIgnoreCase() throws Exception {
    User userToUpdate = _userRepo.findOneByUsername("testuser-editor");
    Assert.assertNotNull(userToUpdate);//from ww  w.  j a  v a 2  s  .c om

    User userToReuseUsername = _userRepo.findOneByUsername("testuser-reviewer");
    Assert.assertNotNull(userToReuseUsername);

    UserDto user = new UserDto();
    // Try to set the username of other existing user with other letter case
    user.setUsername(StringUtils.swapCase(userToReuseUsername.getUsername()));
    user.setName(userToUpdate.getName());
    user.setProfile(userToUpdate.getProfile().toString());
    user.setGroupsEditor(Collections.singletonList("2"));
    user.setEmail(new ArrayList(userToUpdate.getEmailAddresses()));
    user.setEnabled(true);

    Gson gson = new Gson();
    String json = gson.toJson(user);

    this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build();

    this.mockHttpSession = loginAsAdmin();

    // Check 400 is returned and a message indicating that username is duplicated
    this.mockMvc
            .perform(put("/api/users/" + userToUpdate.getId()).content(json)
                    .contentType(MediaType.APPLICATION_JSON).session(this.mockHttpSession)
                    .accept(MediaType.parseMediaType("application/json")))
            .andExpect(jsonPath("$.description",
                    is("Another user with username 'testuser-editor' ignore case already exists")))
            .andExpect(status().is(400));
}