當前位置: 首頁>>代碼示例>>Java>>正文


Java ObjectUtils.allNotNull方法代碼示例

本文整理匯總了Java中org.apache.commons.lang3.ObjectUtils.allNotNull方法的典型用法代碼示例。如果您正苦於以下問題:Java ObjectUtils.allNotNull方法的具體用法?Java ObjectUtils.allNotNull怎麽用?Java ObjectUtils.allNotNull使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.commons.lang3.ObjectUtils的用法示例。


在下文中一共展示了ObjectUtils.allNotNull方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createNode

import org.apache.commons.lang3.ObjectUtils; //導入方法依賴的package包/類
/**
 * 創建節點
 *
 * @param path
 * @param data
 * @param mode
 * @return
 */
public boolean createNode(String path, String data, CreateMode mode) {
    if (!ObjectUtils.allNotNull(zkClient, path)) {
        return Boolean.FALSE;
    }
    try {
        Stat stat = exists(path);
        if (stat == null) {
            mode = mode == null ? CreateMode.PERSISTENT : mode;
            String opResult;
            if (ObjectUtils.allNotNull(data)) {
                opResult = zkClient.create().creatingParentContainersIfNeeded().withMode(mode).forPath(path, data.getBytes(Charsets.UTF_8));
            } else {
                opResult = zkClient.create().creatingParentContainersIfNeeded().withMode(mode).forPath(path);
            }
            return Objects.equal(opResult, path);
        }
        return Boolean.TRUE;
    } catch (Exception e) {
        log.error("create node fail! path: {}, error: {}", path, e);
    }
    return Boolean.FALSE;
}
 
開發者ID:lee123lee123,項目名稱:GoPush,代碼行數:31,代碼來源:ZkUtils.java

示例2: deleteNode

import org.apache.commons.lang3.ObjectUtils; //導入方法依賴的package包/類
/**
 * 刪除節點  遞歸刪除子節點
 *
 * @param path
 * @param version
 * @return
 */
public boolean deleteNode(String path, Integer version) {
    if (!ObjectUtils.allNotNull(zkClient, path)) {
        return Boolean.FALSE;
    }
    try {
        Stat stat = exists(path);
        if (stat != null) {
            if (version == null) {
                zkClient.delete().deletingChildrenIfNeeded().forPath(path);
            } else {
                zkClient.delete().deletingChildrenIfNeeded().withVersion(version).forPath(path);
            }
        }
        return Boolean.TRUE;
    } catch (Exception e) {
        log.error("delete node fail! path: {}, error: {}", path, e);
    }
    return Boolean.FALSE;
}
 
開發者ID:lee123lee123,項目名稱:GoPush,代碼行數:27,代碼來源:ZkUtils.java

示例3: setNodeData

import org.apache.commons.lang3.ObjectUtils; //導入方法依賴的package包/類
/**
 * 設置節點數據
 *
 * @param path
 * @param data
 * @param version
 * @return
 */
public boolean setNodeData(String path, byte[] data, Integer version) {
    if (!ObjectUtils.allNotNull(zkClient, path)) {
        return Boolean.FALSE;
    }
    try {
        Stat stat = exists(path);
        if (stat != null) {
            if (version == null) {
                zkClient.setData().forPath(path, data);
            } else {
                zkClient.setData().withVersion(version).forPath(path, data);
            }
            return Boolean.TRUE;
        }
    } catch (Exception e) {
        log.error("set node data fail! path: {}, error: {}", path, e);
    }
    return Boolean.FALSE;
}
 
開發者ID:lee123lee123,項目名稱:GoPush,代碼行數:28,代碼來源:ZkUtils.java

示例4: listenerPathChildrenCache

import org.apache.commons.lang3.ObjectUtils; //導入方法依賴的package包/類
/**
     * 設置子節點更改監聽
     *
     * @param path
     * @throws Exception
     */
    public boolean listenerPathChildrenCache(String path, BiConsumer<CuratorFramework, PathChildrenCacheEvent> biConsumer) {

        if (!ObjectUtils.allNotNull(zkClient, path, biConsumer)) {
            return Boolean.FALSE;
        }
        try {
            Stat stat = exists(path);
            if (stat != null) {
                PathChildrenCache watcher = new PathChildrenCache(zkClient, path, true);
                watcher.start(PathChildrenCache.StartMode.POST_INITIALIZED_EVENT);
                //該模式下 watcher在重連的時候會自動 rebuild 否則需要重新rebuild
                watcher.getListenable().addListener(biConsumer::accept, pool);
                if (!pathChildrenCaches.contains(watcher)) {
                    pathChildrenCaches.add(watcher);
                }
//                else{
//                    watcher.rebuild();
//                }
                return Boolean.TRUE;
            }
        } catch (Exception e) {
            log.error("listen path children cache fail! path:{} , error:{}", path, e);
        }
        return Boolean.FALSE;
    }
 
開發者ID:lee123lee123,項目名稱:GoPush,代碼行數:32,代碼來源:ZkUtils.java

示例5: readTargetChildsData

import org.apache.commons.lang3.ObjectUtils; //導入方法依賴的package包/類
/**
 * 讀取指定節點的子菜單的值
 *
 * @param path
 * @return
 */
public Map<String, String> readTargetChildsData(String path) {
    if (!ObjectUtils.allNotNull(zkClient, path)) {
        return null;
    }
    Map<String, String> map = null;
    try {
        Stat stat = exists(path);
        if (stat != null) {
            List<String> childrens = zkClient.getChildren().forPath(path);
            GetDataBuilder dataBuilder = zkClient.getData();
            if (childrens != null) {
                map = childrens.stream().collect(Collectors.toMap(Function.identity(), (child) -> {
                    try {
                        return new String(dataBuilder.forPath(ZKPaths.makePath(path, child)), Charsets.UTF_8);
                    } catch (Exception e1) {
                        return null;
                    }
                }));
            }
        }
    } catch (Exception e) {
        log.error("get target childs data fail!, path:{} , error:{}", path, e);
    }
    return map;

}
 
開發者ID:lee123lee123,項目名稱:GoPush,代碼行數:33,代碼來源:ZkUtils.java

示例6: getNodeData

import org.apache.commons.lang3.ObjectUtils; //導入方法依賴的package包/類
/**
 * 獲取指定節點的值
 *
 * @param path
 * @return
 */
public byte[] getNodeData(String path) {
    if (!ObjectUtils.allNotNull(zkClient, path)) {
        return null;
    }
    try {
        Stat stat = exists(path);
        if (stat != null) {
            return zkClient.getData().forPath(path);
        }
    } catch (Exception e) {
        log.error("get node data fail! path: {}, error: {}", path, e);
    }
    return null;
}
 
開發者ID:lee123lee123,項目名稱:GoPush,代碼行數:21,代碼來源:ZkUtils.java

示例7: exists

import org.apache.commons.lang3.ObjectUtils; //導入方法依賴的package包/類
/**
 * 檢查節點是否存在
 *
 * @param path
 * @return
 */
public Stat exists(String path) {
    if (!ObjectUtils.allNotNull(zkClient, path)) {
        return null;
    }
    try {
        return zkClient.checkExists().forPath(path);
    } catch (Exception e) {
        log.error("check node exists fail! path: {}, error: {}", path, e);
    }
    return null;
}
 
開發者ID:lee123lee123,項目名稱:GoPush,代碼行數:18,代碼來源:ZkUtils.java

示例8: build

import org.apache.commons.lang3.ObjectUtils; //導入方法依賴的package包/類
public Baseline build() {
    if (!ObjectUtils.allNotNull(padding)) {
        throw new IllegalStateException("Missing required field.");
    }
    if (percent > 100) {
        throw new IllegalStateException("percent cannot be greater than 100.");
    }
    if (padding < 1) {
        throw new IllegalStateException("padding cannot be less than 1.");
    }
    return new Baseline(this);
}
 
開發者ID:kaygee,項目名稱:timings-client,代碼行數:13,代碼來源:Baseline.java

示例9: setup

import org.apache.commons.lang3.ObjectUtils; //導入方法依賴的package包/類
@Before
public void setup() throws Exception {
    final Profile profile = new ProfilePlistReader(new ProtocolFactory(Collections.singleton(new MantaProtocol()))).read(
        new Local("../profiles/Joyent Triton Object Storage (us-east).cyberduckprofile"));

    final String hostname;
    final Local file;
    if(ObjectUtils.allNotNull(System.getProperty("manta.key_path"), System.getProperty("manta.url"))) {
        file = new Local(System.getProperty("manta.key_path"));
        hostname = new URL(System.getProperty("manta.url")).getHost();
    }
    else {
        final String key = "-----BEGIN RSA PRIVATE KEY-----\nMIIEogIBAAKCAQEAvlJTtsPpgDlSvoYwmWh9h6RMJBiVPQXUwqPgmdQIGjnYCQGD\nxJ7q778mikHA4igWXYOY6jOZ34jxfi+45Hcrloh538/Qa12t+XNHBnuAO6BpcBnh\niIRamr8bJISQZX9KfQmsbZ+8360/N02eOIYX03cMxd4soqQ7q56Jzdt9hyQDVZRT\npUN8CSc3YCkvNINnDBU/jGbDMLX4UB8hGL95sBLqJGkm0i+zihXpXma0/PVaAKnn\npPkNfPwEBDrhsFTd4obOfs5XtcrTOL9lO2GexsjrI4Vhu2CX63SAZ/DFdtvyeydW\nXRtIFVne+4A6xh9/13Z4iE5Onsl0liMQk1Q9KwIDAQABAoIBAEfC9Qu5zSZq9tcd\n8980NfjaK1eE6Wir9TA66Go4N6Hj46BpsMyHe2BQu/BvoJHluaEjCJpuQHu3wA7r\nYZTLlmTZKtMIIbcKCJpB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fc9rwv7GWBKYWzUDrBxEg5cx\nbt2CJUfZImSP9K1uahfc8MP7FFMdnnWPlkOpNc76G8FIpchIsNU=\n-----END RSA PRIVATE KEY----- ";
        file = TemporaryFileServiceFactory.get().create(new AlphanumericRandomStringService().random());
        LocalTouchFactory.get().touch(file);
        IOUtils.write(key, file.getOutputStream(false), Charset.defaultCharset());
        hostname = profile.getDefaultHostname();
    }

    final String user = System.getProperty("manta.user");
    final Host host = new Host(profile, hostname, new Credentials(user).withIdentity(file));
    session = new MantaSession(host, new DisabledX509TrustManager(), new DefaultX509KeyManager());
    session.open(new DisabledHostKeyCallback(), new DisabledLoginCallback());
    session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());
    final String testRoot = "cyberduck-test-" + new AlphanumericRandomStringService().random();
    testPathPrefix = new Path(new MantaAccountHomeInfo(host.getCredentials().getUsername(), host.getDefaultPath()).getAccountPrivateRoot(), testRoot, EnumSet.of(Type.directory));
    session.getClient().putDirectory(testPathPrefix.getAbsolute());
}
 
開發者ID:iterate-ch,項目名稱:cyberduck,代碼行數:29,代碼來源:AbstractMantaTest.java

示例10: build

import org.apache.commons.lang3.ObjectUtils; //導入方法依賴的package包/類
public NavigationTimingRequest build() {
    if (!ObjectUtils.allNotNull(serviceLevelAgreement, log)) {
        throw new IllegalStateException("Missing required field.");
    }
    return new NavigationTimingRequest(this);
}
 
開發者ID:kaygee,項目名稱:timings-client,代碼行數:7,代碼來源:NavigationTimingRequest.java

示例11: build

import org.apache.commons.lang3.ObjectUtils; //導入方法依賴的package包/類
public Log build() {
    if (!ObjectUtils.allNotNull(team, browser, environmentTester, environmentTarget, testInfo)) {
        throw new IllegalStateException("Missing required field.");
    }
    return new Log(this);
}
 
開發者ID:kaygee,項目名稱:timings-client,代碼行數:7,代碼來源:Log.java


注:本文中的org.apache.commons.lang3.ObjectUtils.allNotNull方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。