JsonUtil { public static AclStatus toAclStatus(final Map<?, ?> json) { if (json == null) { return null; } final Map<?, ?> m = (Map<?, ?>) json.get(AclStatus.class.getSimpleName()); AclStatus.Builder aclStatusBuilder = new AclStatus.Builder(); aclStatusBuilder.owner((String) m.get("owner")); aclStatusBuilder.group((String) m.get("group")); aclStatusBuilder.stickyBit((Boolean) m.get("stickyBit")); String permString = (String) m.get("permission"); if (permString != null) { final FsPermission permission = toFsPermission(permString, (Boolean) m.get("aclBit"), (Boolean) m.get("encBit")); aclStatusBuilder.setPermission(permission); } final List<?> entries = (List<?>) m.get("entries"); List<AclEntry> aclEntryList = new ArrayList<AclEntry>(); for (Object entry : entries) { AclEntry aclEntry = AclEntry.parseAclEntry((String) entry, true); aclEntryList.add(aclEntry); } aclStatusBuilder.addEntries(aclEntryList); return aclStatusBuilder.build(); }  static String toJsonString(final Token<? extends TokenIdentifier> token
      ); static Token<? extends TokenIdentifier> toToken(
      final Map<?, ?> m); @SuppressWarnings("unchecked") static Token<DelegationTokenIdentifier> toDelegationToken(
      final Map<?, ?> json); static String toJsonString(final Exception e); static RemoteException toRemoteException(final Map<?, ?> json); static String toJsonString(final String key, final Object value); static String toJsonString(final HdfsFileStatus status,
      boolean includeType); static HdfsFileStatus toFileStatus(final Map<?, ?> json, boolean includesType); static String toJsonString(final LocatedBlocks locatedblocks
      ); static LocatedBlocks toLocatedBlocks(final Map<?, ?> json
      ); static String toJsonString(final ContentSummary contentsummary); static ContentSummary toContentSummary(final Map<?, ?> json); static String toJsonString(final MD5MD5CRC32FileChecksum checksum); static MD5MD5CRC32FileChecksum toMD5MD5CRC32FileChecksum(
      final Map<?, ?> json); static String toJsonString(final AclStatus status); static AclStatus toAclStatus(final Map<?, ?> json); static String toJsonString(final List<XAttr> xAttrs, 
      final XAttrCodec encoding); static String toJsonString(final List<XAttr> xAttrs); static byte[] getXAttr(final Map<?, ?> json, final String name); static Map<String, byte[]> toXAttrs(final Map<?, ?> json); static List<String> toXAttrNames(final Map<?, ?> json);  }
@Test public void testToAclStatus() throws IOException { String jsonString = "{\"AclStatus\":{\"entries\":[\"user::rwx\",\"user:user1:rw-\",\"group::rw-\",\"other::r-x\"],\"group\":\"supergroup\",\"owner\":\"testuser\",\"stickyBit\":false}}"; ObjectReader reader = new ObjectMapper().reader(Map.class); Map<?, ?> json = reader.readValue(jsonString); List<AclEntry> aclSpec = Lists.newArrayList(aclEntry(ACCESS, USER, ALL), aclEntry(ACCESS, USER, "user1", READ_WRITE), aclEntry(ACCESS, GROUP, READ_WRITE), aclEntry(ACCESS, OTHER, READ_EXECUTE)); AclStatus.Builder aclStatusBuilder = new AclStatus.Builder(); aclStatusBuilder.owner("testuser"); aclStatusBuilder.group("supergroup"); aclStatusBuilder.addEntries(aclSpec); aclStatusBuilder.stickyBit(false); Assert.assertEquals("Should be equal", aclStatusBuilder.build(), JsonUtil.toAclStatus(json)); }