Example usage for java.lang.reflect Modifier PROTECTED

List of usage examples for java.lang.reflect Modifier PROTECTED

Introduction

In this page you can find the example usage for java.lang.reflect Modifier PROTECTED.

Prototype

int PROTECTED

To view the source code for java.lang.reflect Modifier PROTECTED.

Click Source Link

Document

The int value representing the protected modifier.

Usage

From source file:Main.java

public static void main(String... args) throws Exception {
    Class<?> c = Class.forName("java.lang.String");
    Constructor[] allConstructors = c.getDeclaredConstructors();
    for (Constructor ctor : allConstructors) {
        int searchMod = Modifier.PROTECTED;
        int mods = accessModifiers(ctor.getModifiers());
        if (searchMod == mods) {
            System.out.println(ctor);
        }/*w  w  w  .  j av a  2  s.  c  om*/
    }
}

From source file:Main.java

private static int accessModifiers(int m) {
    return m & Modifier.PROTECTED;
}

From source file:Main.java

private static int accessModifiers(int m) {
    return m & (Modifier.PUBLIC | Modifier.PRIVATE | Modifier.PROTECTED);
}

From source file:Main.java

private static int modifierFromString(String s) {
    if ("public".equals(s))
        return Modifier.PUBLIC;
    else if ("protected".equals(s))
        return Modifier.PROTECTED;
    else if ("private".equals(s))
        return Modifier.PRIVATE;
    else if ("package-private".equals(s))
        return 0;
    else/*from  w w w  . j  av  a  2s .c  o m*/
        return -1;
}

From source file:com.hihframework.core.utils.ReflectUtil.java

public static final String[] getProtectedFieldsName(Object obj) {
    return getFieldsName(obj, Modifier.PROTECTED);
}

From source file:Spy.java

private static int modifierFromString(String s) {
    int m = 0x0;/*w w  w.  ja v a 2 s.c  o m*/
    if ("public".equals(s))
        m |= Modifier.PUBLIC;
    else if ("protected".equals(s))
        m |= Modifier.PROTECTED;
    else if ("private".equals(s))
        m |= Modifier.PRIVATE;
    else if ("static".equals(s))
        m |= Modifier.STATIC;
    else if ("final".equals(s))
        m |= Modifier.FINAL;
    else if ("transient".equals(s))
        m |= Modifier.TRANSIENT;
    else if ("volatile".equals(s))
        m |= Modifier.VOLATILE;
    return m;
}

From source file:com.hihframework.core.utils.ReflectUtil.java

public static final String[] getProtectedMethodsName(Object obj) {
    return getMethodsName(obj, Modifier.PROTECTED, null);
}

From source file:controllers.GroupUsersController.java

public Result getGroupList(Long userID, String format) {
    if (userID == null) {
        System.out.println("user id is null or empty!");
        return Common.badRequestWrapper("user id is null or empty!");
    }/*from w w w .  j ava2 s  . c o m*/

    List<GroupUsers> groups = groupUsersRepository.findByUserId(userID);
    if (groups == null) {
        System.out.println("The group does not exist!");
        return Common.badRequestWrapper("The group does not exist!");
    }

    for (GroupUsers group : groups) {
        for (int i = 0; i < group.getGroupMembers().size(); i++) {
            Set<User> empty = new HashSet<>();
            group.getGroupMembers().get(i).setFollowers(empty);
            group.getGroupMembers().get(i).setFriends(empty);
        }
    }
    String result = new String();
    if (format.equals("json")) {
        result = new GsonBuilder().excludeFieldsWithModifiers(Modifier.PROTECTED).create().toJson(groups);
    }

    return ok(result);
}

From source file:controllers.SuggestionsController.java

public Result getSuggestionForWorkflow(Long workflowId) {
    Workflow workflow = workflowRepository.findById(workflowId);
    if (workflow == null) {
        return Common.badRequestWrapper("Workflow doesn't exist!");
    }//from   w  w  w .  j  a v a  2 s  .c  om

    List<Suggestions> suggestionsList = suggestionsRepository.findByWorkflowId(workflowId);
    return created(
            new GsonBuilder().excludeFieldsWithModifiers(Modifier.PROTECTED).create().toJson(suggestionsList));
}

From source file:controllers.GroupUsersController.java

public Result getGroupMember(Long groupId, String format) {
    if (groupId == null) {
        System.out.println("Id not created, please enter valid user");
        return Common.badRequestWrapper("Id not created, please enter valid user");
    }//from w  w  w  . j  av  a 2s .c  o  m

    GroupUsers group = groupUsersRepository.findById(groupId);
    List<User> groupMembers = group.getGroupMembers();
    for (User groupMember : groupMembers) {
        groupMember.setPassword("******");
    }

    String result = new String();
    if (format.equals("json")) {
        result = new GsonBuilder().excludeFieldsWithModifiers(Modifier.PROTECTED).create().toJson(groupMembers);
    }

    return ok(result);
}