Example usage for com.google.common.primitives Chars saturatedCast

List of usage examples for com.google.common.primitives Chars saturatedCast

Introduction

In this page you can find the example usage for com.google.common.primitives Chars saturatedCast.

Prototype

public static char saturatedCast(long value) 

Source Link

Document

Returns the char nearest in value to value .

Usage

From source file:org.apache.james.server.core.MailImpl.java

private static void detectPossibleLoop(String currentName, int loopThreshold, char separator)
        throws MessagingException {
    long occurrences = currentName.chars().filter(c -> Chars.saturatedCast(c) == separator).count();

    // It looks like a configuration loop. It's better to stop.
    if (occurrences > loopThreshold) {
        throw new MessagingException(
                "Unable to create a new message name: too long. Possible loop in config.xml.");
    }//w w  w.j a va 2s.c  o m
}